Re: [PATCH] commit: Add -f, --fixes commit option to add Fixes: line

2013-10-31 Thread Duy Nguyen
On Thu, Oct 31, 2013 at 1:12 AM, Johan Herland jo...@herland.net wrote:
 Yes, we do lack a good infrastructure for managing Git hooks from
 multiple sources. It makes people afraid to use them, because they
 might conflict with hooks from another source. There are (off the top
 of my head):

  - personal hooks (I want this behaviour in my repo(s))
  - project hooks (In this project we follow these conventions)
  - system hooks (This host runs gitolite (or whatever) which needs
 these hooks...)
  - default hooks (Some of the core Git code could have be
 implemented as hooks (e.g. --signoff), but is instead put into core
 Git)

 Maybe if we solved that problem, we could actually make use of hooks
 instead of adding code to our git configs (by which I mean config
 directives that are flexible enough to encode all kinds of semantics
 and behaviors that are probably better expressed in real code...).

OK how about, if $GIT_DIR/hooks/something is a directory, then the
directory must contain a file named index, listing all the hooks of
type something. All the hooks in index will be executed in the
listing order. There could be directories inside .git/hooks/something
to help categorize the scripts, so project hooks stay in project
subdirectory and so on.

With this we could provide git hook command to manipulate hooks and
test out the new combination of hooks. We could even select what
scripts not to run for a particular run, say you don't want the s-o-b
hook active when you commit this thing, you could run

  git commit --exclude-hooks=pre-commit-msg/s-o-b

You could exclude hooks by pattern as well

  git commit --exclude-hooks=pre-commit-msg/projects/*

Or run an unsinstalled hook just one time

  git commit --include-hooks=/path/to/my/hook

Hooks like Fixes may need input from the user. The hook could bail
out if the required input is not given. But it maybe a good idea for
git to check and reject before running hooks, if the input is not
specified (e.g. from command line). I guess those extra info has to be
in .git/config and be added to .git/config by git hook command,
unless we have some convention to express those without running the hook.

For old Git versions that does not support this scheme, as directories
usually have u+x, the hook directory should be mistaken as an
executable and rejected when executed (permission denied in my test),
which gives user a good warning that this repo should not be used with
this git version.
-- 
Duy
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4] remote-curl: fix large pushes with GSSAPI

2013-10-31 Thread Jeff King
On Wed, Oct 30, 2013 at 10:40:30PM +, brian m. carlson wrote:

 If you would split it out, that would be great.  Then I'll simply rebase
 my patch on top of yours and go from there.

I just included your patch on top, since it was the residue left over
after committing my refactoring. Please read over the result to make
sure I am not defaming you. :)

I noticed while committing the first patch that we do not actually
follow the do not look at curl after finish_active_slot rule for the
content-type. Again, we get away with it because we are not running
multiple slots at the time (we only check content-type during the
initial discovery).

I think the refactoring here is the cleanest thing by the existing
rules, but I also think we could get away with the somewhat simpler
patch of just teaching probe_rpc to grab the AUTHAVAIL (because it still
has the old slot and does not need to call get_active_slot again, and
because we know we are only using a single slot).

Going through all of this, I can't help but be annoyed at how much http
baggage we are carrying around for the curl_multi code for parallel
fetches, which is only used for dumb http. The smart-http code would be
happy with a single curl handle we used each time. But I imagine there
are still people relying on dumb http, and dropping the parallel fetch
would be a pretty severe regression for them.

  [1/3]: http: return curl's AUTHAVAIL via slot_results
  [2/3]: remote-curl: pass curl slot_results back through run_slot
  [3/3]: remote-curl: fix large pushes with GSSAPI

-Peff
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] http: return curl's AUTHAVAIL via slot_results

2013-10-31 Thread Jeff King
Callers of the http code may want to know which auth types
were available for the previous request. But after finishing
with the curl slot, they are not supposed to look at the
curl handle again. We already handle returning other
information via the slot_results struct; let's add a flag to
check the available auth.

Note that older versions of curl did not support this, so we
simply return 0 (something like -1 would be worse, as the
value is a bitflag and we might accidentally set a flag).
This is sufficient for the callers planned in this series,
who only trigger some optional behavior if particular bits
are set, and can live with a fake no bits answer.

Signed-off-by: Jeff King p...@peff.net
---
 http.c | 6 ++
 http.h | 1 +
 2 files changed, 7 insertions(+)

diff --git a/http.c b/http.c
index 0ddb164..5c51865 100644
--- a/http.c
+++ b/http.c
@@ -761,6 +761,12 @@ void finish_active_slot(struct active_request_slot *slot)
if (slot-results != NULL) {
slot-results-curl_result = slot-curl_result;
slot-results-http_code = slot-http_code;
+#if LIBCURL_VERSION_NUM = 0x070a08
+   curl_easy_getinfo(slot-curl, CURLINFO_HTTPAUTH_AVAIL,
+ slot-results-auth_avail);
+#else
+   slot-results-auth_avail = 0;
+#endif
}
 
/* Run callback if appropriate */
diff --git a/http.h b/http.h
index d77c1b5..81d4843 100644
--- a/http.h
+++ b/http.h
@@ -54,6 +54,7 @@
 struct slot_results {
CURLcode curl_result;
long http_code;
+   long auth_avail;
 };
 
 struct active_request_slot {
-- 
1.8.4.1.898.g8bf8a41.dirty

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] remote-curl: pass curl slot_results back through run_slot

2013-10-31 Thread Jeff King
Some callers may want to know more than just the integer
error code we return. Let them optionally pass a
slot_results struct to fill in (or NULL if they do not
care). In either case we continue to return the integer
code.

We can also give probe_rpc the same treatment (since it
builds directly on run_slot).

Signed-off-by: Jeff King p...@peff.net
---
 remote-curl.c | 22 +-
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/remote-curl.c b/remote-curl.c
index b5ebe01..79db21e 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -383,25 +383,29 @@ static size_t rpc_in(char *ptr, size_t eltsize,
return size;
 }
 
-static int run_slot(struct active_request_slot *slot)
+static int run_slot(struct active_request_slot *slot,
+   struct slot_results *results)
 {
int err;
-   struct slot_results results;
+   struct slot_results results_buf;
 
-   slot-results = results;
+   if (!results)
+   results = results_buf;
+
+   slot-results = results;
slot-curl_result = curl_easy_perform(slot-curl);
finish_active_slot(slot);
 
-   err = handle_curl_result(results);
+   err = handle_curl_result(results);
if (err != HTTP_OK  err != HTTP_REAUTH) {
error(RPC failed; result=%d, HTTP code = %ld,
- results.curl_result, results.http_code);
+ results-curl_result, results-http_code);
}
 
return err;
 }
 
-static int probe_rpc(struct rpc_state *rpc)
+static int probe_rpc(struct rpc_state *rpc, struct slot_results *results)
 {
struct active_request_slot *slot;
struct curl_slist *headers = NULL;
@@ -423,7 +427,7 @@ static int probe_rpc(struct rpc_state *rpc)
curl_easy_setopt(slot-curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
curl_easy_setopt(slot-curl, CURLOPT_FILE, buf);
 
-   err = run_slot(slot);
+   err = run_slot(slot, results);
 
curl_slist_free_all(headers);
strbuf_release(buf);
@@ -462,7 +466,7 @@ static int post_rpc(struct rpc_state *rpc)
 
if (large_request) {
do {
-   err = probe_rpc(rpc);
+   err = probe_rpc(rpc, NULL);
} while (err == HTTP_REAUTH);
if (err != HTTP_OK)
return -1;
@@ -561,7 +565,7 @@ retry:
curl_easy_setopt(slot-curl, CURLOPT_WRITEFUNCTION, rpc_in);
curl_easy_setopt(slot-curl, CURLOPT_FILE, rpc);
 
-   err = run_slot(slot);
+   err = run_slot(slot, NULL);
if (err == HTTP_REAUTH  !large_request)
goto retry;
if (err != HTTP_OK)
-- 
1.8.4.1.898.g8bf8a41.dirty

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] remote-curl: fix large pushes with GSSAPI

2013-10-31 Thread Jeff King
From: brian m. carlson sand...@crustytoothpaste.net

Due to an interaction between the way libcurl handles GSSAPI
authentication over HTTP and the way git uses libcurl, large
pushes (those over http.postBuffer bytes) would fail due to
an authentication failure requiring a rewind of the curl
buffer.  Such a rewind was not possible because the data did
not fit into the entire buffer.

Enable the use of the Expect: 100-continue header for large
requests where the server offers GSSAPI authentication to
avoid this issue, since the request would otherwise fail.
This allows git to get the authentication data right before
sending the pack contents.  Existing cases where pushes
would succeed, including small requests using GSSAPI, still
disable the use of 100 Continue, as it causes problems for
some remote HTTP implementations (servers and proxies).

Signed-off-by: brian m. carlson sand...@crustytoothpaste.net
Signed-off-by: Jeff King p...@peff.net
---
 remote-curl.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/remote-curl.c b/remote-curl.c
index 79db21e..f646b5f 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -442,6 +442,7 @@ static int post_rpc(struct rpc_state *rpc)
char *gzip_body = NULL;
size_t gzip_size = 0;
int err, large_request = 0;
+   int needs_100_continue = 0;
 
/* Try to load the entire request, if we can fit it into the
 * allocated buffer space we can use HTTP/1.0 and avoid the
@@ -465,16 +466,22 @@ static int post_rpc(struct rpc_state *rpc)
}
 
if (large_request) {
+   struct slot_results results;
+
do {
-   err = probe_rpc(rpc, NULL);
+   err = probe_rpc(rpc, results);
} while (err == HTTP_REAUTH);
if (err != HTTP_OK)
return -1;
+
+   if (results.auth_avail  CURLAUTH_GSSNEGOTIATE)
+   needs_100_continue = 1;
}
 
headers = curl_slist_append(headers, rpc-hdr_content_type);
headers = curl_slist_append(headers, rpc-hdr_accept);
-   headers = curl_slist_append(headers, Expect:);
+   headers = curl_slist_append(headers, needs_100_continue ?
+   Expect: 100-continue : Expect:);
 
 retry:
slot = get_active_slot();
-- 
1.8.4.1.898.g8bf8a41.dirty
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] gitk: Add a horizontal scrollbar for commit history

2013-10-31 Thread Paul Mackerras
On Wed, Oct 30, 2013 at 01:47:08PM +0100, Nicolas Cornu wrote:
 This is useful on all our repos, every times, as we put a tag per day.
 If the HEAD didn't move during 150 days, we got 150 tags.

Here is a patch that I did some time ago but have never pushed out.
Do you think it is an improvement when using gitk on a repo with lots
of tags?

Paul.

[PATCH] gitk: Tag display improvements

When a commit has many tags, the tag icons in the graph display can
easily become so wide as to push the commit message off the right-hand
edge of the graph display pane.  This changes the display so that if
there are more than 3 tags or they would take up more than a quarter
of the width of the pane, we instead display a single tag icon with
a legend inside it like 4 tags  If the user clicks on the tag
icon, gitk then displays all the tags in the diff display pane.

Signed-off-by: Paul Mackerras pau...@samba.org
---
 gitk | 96 ++--
 1 file changed, 83 insertions(+), 13 deletions(-)

diff --git a/gitk b/gitk
index 5cd00d8..0bdb146 100755
--- a/gitk
+++ b/gitk
@@ -2385,6 +2385,7 @@ proc makewindow {} {
 $ctext tag conf found -back $foundbgcolor
 $ctext tag conf currentsearchhit -back $currentsearchhitbgcolor
 $ctext tag conf wwrap -wrap word
+$ctext tag conf bold -font textfontbold
 
 .pwbottom add .bleft
 if {!$use_ttk} {
@@ -6387,6 +6388,25 @@ proc bindline {t id} {
 $canv bind $t Button-1 lineclick %x %y $id 1
 }
 
+proc graph_pane_width {} {
+global use_ttk
+
+if {$use_ttk} {
+   set g [.tf.histframe.pwclist sashpos 0]
+} else {
+   set g [.tf.histframe.pwclist sash coord 0]
+}
+return [lindex $g 0]
+}
+
+proc totalwidth {l font extra} {
+set tot 0
+foreach str $l {
+   set tot [expr {$tot + [font measure $font $str] + $extra}]
+}
+return $tot
+}
+
 proc drawtags {id x xt y1} {
 global idtags idheads idotherrefs mainhead
 global linespc lthickness
@@ -6398,9 +6418,27 @@ proc drawtags {id x xt y1} {
 set marks {}
 set ntags 0
 set nheads 0
+set singletag 0
+set maxtags 3
+set maxtagpct 25
+set maxwidth [expr {[graph_pane_width] * $maxtagpct / 100}]
+set delta [expr {int(0.5 * ($linespc - $lthickness))}]
+set extra [expr {$delta + $lthickness + $linespc}]
+
 if {[info exists idtags($id)]} {
set marks $idtags($id)
set ntags [llength $marks]
+   if {$ntags  $maxtags ||
+   [totalwidth $marks mainfont $extra]  $maxwidth} {
+   # show just a single n tags... tag
+   set singletag 1
+   if {$ntags == 1} {
+   set marks [list tag...]
+   } else {
+   set marks [list [format %d tags... $ntags]]
+   }
+   set ntags 1
+   }
 }
 if {[info exists idheads($id)]} {
set marks [concat $marks $idheads($id)]
@@ -6413,7 +6451,6 @@ proc drawtags {id x xt y1} {
return $xt
 }
 
-set delta [expr {int(0.5 * ($linespc - $lthickness))}]
 set yt [expr {$y1 - 0.5 * $linespc}]
 set yb [expr {$yt + $linespc - 1}]
 set xvals {}
@@ -6428,7 +6465,7 @@ proc drawtags {id x xt y1} {
}
lappend xvals $xt
lappend wvals $wid
-   set xt [expr {$xt + $delta + $wid + $lthickness + $linespc}]
+   set xt [expr {$xt + $wid + $extra}]
 }
 set t [$canv create line $x $y1 [lindex $xvals end] $y1 \
   -width $lthickness -fill $reflinecolor -tags tag.$id]
@@ -6444,7 +6481,12 @@ proc drawtags {id x xt y1} {
   $xr $yt $xr $yb $xl $yb $x [expr {$yb - $delta}] \
   -width 1 -outline $tagoutlinecolor -fill $tagbgcolor \
   -tags tag.$id]
-   $canv bind $t 1 [list showtag $tag_quoted 1]
+   if {$singletag} {
+   set tagclick [list showtags $id 1]
+   } else {
+   set tagclick [list showtag $tag_quoted 1]
+   }
+   $canv bind $t 1 $tagclick
set rowtextx([rowofcommit $id]) [expr {$xr + $linespc}]
} else {
# draw a head or other ref
@@ -6471,7 +6513,7 @@ proc drawtags {id x xt y1} {
set t [$canv create text $xl $y1 -anchor w -text $tag -fill 
$headfgcolor \
   -font $font -tags [list tag.$id text]]
if {$ntags = 0} {
-   $canv bind $t 1 [list showtag $tag_quoted 1]
+   $canv bind $t 1 $tagclick
} elseif {$nheads = 0} {
$canv bind $t $ctxbut [list headmenu %X %Y $id $tag_quoted]
}
@@ -10878,6 +10920,23 @@ proc listrefs {id} {
 return [list $x $y $z]
 }
 
+proc add_tag_ctext {tag} {
+global ctext cached_tagcontent tagids
+
+if {![info exists cached_tagcontent($tag)]} {
+   catch {
+   set cached_tagcontent($tag) [exec git cat-file -p $tag]
+   }
+}
+$ctext insert end [mc Tag]: $tag\n bold
+if {[info exists 

[PATCH 01/16] merge: simplify ff-only option

2013-10-31 Thread Felipe Contreras
No functional changes.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 builtin/merge.c | 11 ++-
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/builtin/merge.c b/builtin/merge.c
index 02a69c1..41fb66d 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -186,13 +186,6 @@ static int option_parse_n(const struct option *opt,
return 0;
 }
 
-static int option_parse_ff_only(const struct option *opt,
- const char *arg, int unset)
-{
-   fast_forward = FF_ONLY;
-   return 0;
-}
-
 static struct option builtin_merge_options[] = {
{ OPTION_CALLBACK, 'n', NULL, NULL, NULL,
N_(do not show a diffstat at the end of the merge),
@@ -210,9 +203,9 @@ static struct option builtin_merge_options[] = {
OPT_BOOL('e', edit, option_edit,
N_(edit message before committing)),
OPT_SET_INT(0, ff, fast_forward, N_(allow fast-forward (default)), 
FF_ALLOW),
-   { OPTION_CALLBACK, 0, ff-only, NULL, NULL,
+   { OPTION_SET_INT, 0, ff-only, fast_forward, NULL,
N_(abort if fast-forward is not possible),
-   PARSE_OPT_NOARG | PARSE_OPT_NONEG, option_parse_ff_only },
+   PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, FF_ONLY },
OPT_RERERE_AUTOUPDATE(allow_rerere_auto),
OPT_BOOL(0, verify-signatures, verify_signatures,
N_(Verify that the named commit has a valid GPG signature)),
-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 00/16] Trivial patches

2013-10-31 Thread Felipe Contreras
Most of these have been sent before, but were not applied for one reason or
another.

Felipe Contreras (16):
  merge: simplify ff-only option
  t: replace pulls with merges
  pull: cleanup documentation
  fetch: add missing documentation
  revision: add missing include
  shortlog: add missing declaration
  branch: trivial style fix
  sha1-name: trivial style cleanup
  transport-helper: trivial style fix
  describe: trivial style fixes
  pretty: trivial style fix
  revision: trivial style fixes
  diff: trivial style fix
  run-command: trivial style fixes
  setup: trivial style fixes
  add: avoid yoda conditions

 Documentation/git-fetch.txt|  3 +++
 Documentation/git-pull.txt |  4 ++--
 builtin/add.c  |  2 +-
 builtin/branch.c   |  3 +--
 builtin/describe.c |  7 +++
 builtin/diff.c |  2 +-
 builtin/merge.c| 11 ++-
 pretty.c   |  2 +-
 revision.c | 14 ++
 revision.h |  1 +
 run-command.c  | 13 +
 setup.c|  4 ++--
 sha1_name.c|  1 -
 shortlog.h |  2 ++
 t/annotate-tests.sh|  2 +-
 t/t4200-rerere.sh  |  2 +-
 t/t9114-git-svn-dcommit-merge.sh   |  2 +-
 t/t9500-gitweb-standalone-no-errors.sh |  2 +-
 transport-helper.c |  1 +
 19 files changed, 35 insertions(+), 43 deletions(-)

-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/16] t: replace pulls with merges

2013-10-31 Thread Felipe Contreras
This is what the code intended.

No functional changes.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 t/annotate-tests.sh| 2 +-
 t/t4200-rerere.sh  | 2 +-
 t/t9114-git-svn-dcommit-merge.sh   | 2 +-
 t/t9500-gitweb-standalone-no-errors.sh | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
index 99caa42..c9d105d 100644
--- a/t/annotate-tests.sh
+++ b/t/annotate-tests.sh
@@ -92,7 +92,7 @@ test_expect_success 'blame 2 authors + 1 branch2 author' '
 '
 
 test_expect_success 'merge branch1  branch2' '
-   git pull . branch1
+   git merge branch1
 '
 
 test_expect_success 'blame 2 authors + 2 merged-in authors' '
diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh
index 7ff..cf19eb7 100755
--- a/t/t4200-rerere.sh
+++ b/t/t4200-rerere.sh
@@ -172,7 +172,7 @@ test_expect_success 'first postimage wins' '
git show second^:a1 | sed s/To die: t/To die! T/ a1 
git commit -q -a -m third 
 
-   test_must_fail git pull . first 
+   test_must_fail git merge first 
# rerere kicked in
! grep ^===\$ a1 
test_cmp expect a1
diff --git a/t/t9114-git-svn-dcommit-merge.sh b/t/t9114-git-svn-dcommit-merge.sh
index f524d2f..d33d714 100755
--- a/t/t9114-git-svn-dcommit-merge.sh
+++ b/t/t9114-git-svn-dcommit-merge.sh
@@ -62,7 +62,7 @@ test_expect_success 'setup git mirror and merge' '
echo friend  README 
cat tmp  README 
git commit -a -m friend 
-   git pull . merge
+   git merge merge
'
 
 test_debug 'gitk --all  sleep 1'
diff --git a/t/t9500-gitweb-standalone-no-errors.sh 
b/t/t9500-gitweb-standalone-no-errors.sh
index 718014d..e74b9ab 100755
--- a/t/t9500-gitweb-standalone-no-errors.sh
+++ b/t/t9500-gitweb-standalone-no-errors.sh
@@ -328,7 +328,7 @@ test_expect_success \
 git add b 
 git commit -a -m On branch 
 git checkout master 
-git pull . b 
+git merge b 
 git tag merge_commit'
 
 test_expect_success \
-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/16] shortlog: add missing declaration

2013-10-31 Thread Felipe Contreras
Otherwise we would have to include commit.h.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 shortlog.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/shortlog.h b/shortlog.h
index de4f86f..54bc07c 100644
--- a/shortlog.h
+++ b/shortlog.h
@@ -19,6 +19,8 @@ struct shortlog {
struct string_list mailmap;
 };
 
+struct commit;
+
 void shortlog_init(struct shortlog *log);
 
 void shortlog_add_commit(struct shortlog *log, struct commit *commit);
-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 15/16] setup: trivial style fixes

2013-10-31 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 setup.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/setup.c b/setup.c
index dbf4138..5432a31 100644
--- a/setup.c
+++ b/setup.c
@@ -563,7 +563,7 @@ static const char *setup_git_directory_gently_1(int 
*nongit_ok)
 {
const char *env_ceiling_dirs = getenv(CEILING_DIRECTORIES_ENVIRONMENT);
struct string_list ceiling_dirs = STRING_LIST_INIT_DUP;
-   static char cwd[PATH_MAX+1];
+   static char cwd[PATH_MAX + 1];
const char *gitdirenv, *ret;
char *gitfile;
int len, offset, offset_parent, ceil_offset = -1;
@@ -578,7 +578,7 @@ static const char *setup_git_directory_gently_1(int 
*nongit_ok)
if (nongit_ok)
*nongit_ok = 0;
 
-   if (!getcwd(cwd, sizeof(cwd)-1))
+   if (!getcwd(cwd, sizeof(cwd) - 1))
die_errno(Unable to read current working directory);
offset = len = strlen(cwd);
 
-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/16] revision: add missing include

2013-10-31 Thread Felipe Contreras
Otherwise we might not have 'struct diff_options'.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 revision.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/revision.h b/revision.h
index e7f1d21..89132df 100644
--- a/revision.h
+++ b/revision.h
@@ -5,6 +5,7 @@
 #include grep.h
 #include notes.h
 #include commit.h
+#include diff.h
 
 #define SEEN   (1u0)
 #define UNINTERESTING   (1u1)
-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/16] transport-helper: trivial style fix

2013-10-31 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 transport-helper.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/transport-helper.c b/transport-helper.c
index b32e2d6..673b7c2 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -269,6 +269,7 @@ static const char *unsupported_options[] = {
TRANS_OPT_THIN,
TRANS_OPT_KEEP
};
+
 static const char *boolean_options[] = {
TRANS_OPT_THIN,
TRANS_OPT_KEEP,
-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 16/16] add: avoid yoda conditions

2013-10-31 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 builtin/add.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/add.c b/builtin/add.c
index 226f758..9b30356 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -429,7 +429,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
argc--;
argv++;
 
-   if (0 = addremove_explicit)
+   if (addremove_explicit = 0)
addremove = addremove_explicit;
else if (take_worktree_changes  ADDREMOVE_DEFAULT)
addremove = 0; /* -u was given but not -A */
-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/16] revision: trivial style fixes

2013-10-31 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 revision.c | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/revision.c b/revision.c
index 3fdea51..956040c 100644
--- a/revision.c
+++ b/revision.c
@@ -1519,7 +1519,7 @@ struct cmdline_pathspec {
 static void append_prune_data(struct cmdline_pathspec *prune, const char **av)
 {
while (*av) {
-   ALLOC_GROW(prune-path, prune-nr+1, prune-alloc);
+   ALLOC_GROW(prune-path, prune-nr + 1, prune-alloc);
prune-path[prune-nr++] = *(av++);
}
 }
@@ -1531,7 +1531,7 @@ static void read_pathspec_from_stdin(struct rev_info 
*revs, struct strbuf *sb,
int len = sb-len;
if (len  sb-buf[len - 1] == '\n')
sb-buf[--len] = '\0';
-   ALLOC_GROW(prune-path, prune-nr+1, prune-alloc);
+   ALLOC_GROW(prune-path, prune-nr + 1, prune-alloc);
prune-path[prune-nr++] = xstrdup(sb-buf);
}
 }
@@ -2134,7 +2134,7 @@ int setup_revisions(int argc, const char **argv, struct 
rev_info *revs, struct s
 *  call init_pathspec() to set revs-prune_data here.
 * }
 */
-   ALLOC_GROW(prune_data.path, prune_data.nr+1, prune_data.alloc);
+   ALLOC_GROW(prune_data.path, prune_data.nr + 1, 
prune_data.alloc);
prune_data.path[prune_data.nr++] = NULL;
parse_pathspec(revs-prune_data, 0, 0,
   revs-prefix, prune_data.path);
@@ -2987,7 +2987,7 @@ static struct commit *get_revision_internal(struct 
rev_info *revs)
if (revs-max_count) {
c = get_revision_1(revs);
if (c) {
-   while (0  revs-skip_count) {
+   while (revs-skip_count  0) {
revs-skip_count--;
c = get_revision_1(revs);
if (!c)
@@ -3002,9 +3002,8 @@ static struct commit *get_revision_internal(struct 
rev_info *revs)
if (c)
c-object.flags |= SHOWN;
 
-   if (!revs-boundary) {
+   if (!revs-boundary)
return c;
-   }
 
if (!c) {
/*
@@ -3050,9 +3049,8 @@ struct commit *get_revision(struct rev_info *revs)
 
if (revs-reverse) {
reversed = NULL;
-   while ((c = get_revision_internal(revs))) {
+   while ((c = get_revision_internal(revs)))
commit_list_insert(c, reversed);
-   }
revs-commits = reversed;
revs-reverse = 0;
revs-reverse_output_stage = 1;
-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 14/16] run-command: trivial style fixes

2013-10-31 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 run-command.c | 13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/run-command.c b/run-command.c
index 1b7f88e..3914d9c 100644
--- a/run-command.c
+++ b/run-command.c
@@ -406,13 +406,12 @@ fail_pipe:
unsetenv(*cmd-env);
}
}
-   if (cmd-git_cmd) {
+   if (cmd-git_cmd)
execv_git_cmd(cmd-argv);
-   } else if (cmd-use_shell) {
+   else if (cmd-use_shell)
execv_shell_cmd(cmd-argv);
-   } else {
+   else
sane_execvp(cmd-argv[0], (char *const*) cmd-argv);
-   }
if (errno == ENOENT) {
if (!cmd-silent_exec_failure)
error(cannot run %s: %s, cmd-argv[0],
@@ -446,7 +445,6 @@ fail_pipe:
cmd-pid = -1;
}
close(notify_pipe[0]);
-
 }
 #else
 {
@@ -480,11 +478,10 @@ fail_pipe:
if (cmd-env)
env = make_augmented_environ(cmd-env);
 
-   if (cmd-git_cmd) {
+   if (cmd-git_cmd)
cmd-argv = prepare_git_cmd(cmd-argv);
-   } else if (cmd-use_shell) {
+   else if (cmd-use_shell)
cmd-argv = prepare_shell_cmd(cmd-argv);
-   }
 
cmd-pid = mingw_spawnvpe(cmd-argv[0], cmd-argv, env, cmd-dir,
  fhin, fhout, fherr);
-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 11/16] pretty: trivial style fix

2013-10-31 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 pretty.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pretty.c b/pretty.c
index b4e32b7..962e82b 100644
--- a/pretty.c
+++ b/pretty.c
@@ -497,7 +497,7 @@ void pp_user_info(struct pretty_print_context *pp,
 static int is_empty_line(const char *line, int *len_p)
 {
int len = *len_p;
-   while (len  isspace(line[len-1]))
+   while (len  isspace(line[len - 1]))
len--;
*len_p = len;
return !len;
-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/16] pull: cleanup documentation

2013-10-31 Thread Felipe Contreras
'origin/master' is very clear, no need to specify the 'remotes/' prefix,
or babysit the user.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 Documentation/git-pull.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt
index beea10b..03a39bc 100644
--- a/Documentation/git-pull.txt
+++ b/Documentation/git-pull.txt
@@ -39,7 +39,7 @@ Assume the following history exists and the current branch is
 `master`:
 
 
- A---B---C master on origin
+ A---B---C origin/master
 /
 D---E---F---G master
 
@@ -51,7 +51,7 @@ result in a new commit along with the names of the two parent 
commits
 and a log message from the user describing the changes.
 
 
- A---B---C remotes/origin/master
+ A---B---C origin/master
 / \
 D---E---F---G---H master
 
-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/16] diff: trivial style fix

2013-10-31 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 builtin/diff.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/diff.c b/builtin/diff.c
index 2fb8c5d..adb93a9 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -169,7 +169,7 @@ static int builtin_diff_tree(struct rev_info *revs,
if (ent1-item-flags  UNINTERESTING)
swap = 1;
sha1[swap] = ent0-item-sha1;
-   sha1[1-swap] = ent1-item-sha1;
+   sha1[1 - swap] = ent1-item-sha1;
diff_tree_sha1(sha1[0], sha1[1], , revs-diffopt);
log_tree_diff_flush(revs);
return 0;
-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/16] sha1-name: trivial style cleanup

2013-10-31 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 sha1_name.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/sha1_name.c b/sha1_name.c
index 0e5fe7f..e9c2999 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -343,7 +343,6 @@ static int get_short_sha1(const char *name, int len, 
unsigned char *sha1,
return status;
 }
 
-
 int for_each_abbrev(const char *prefix, each_abbrev_fn fn, void *cb_data)
 {
char hex_pfx[40];
-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/16] describe: trivial style fixes

2013-10-31 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 builtin/describe.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/builtin/describe.c b/builtin/describe.c
index b9d3603..6f62109 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -9,7 +9,7 @@
 #include hash.h
 #include argv-array.h
 
-#define SEEN   (1u0)
+#define SEEN   (1u  0)
 #define MAX_TAGS   (FLAG_BITS - 1)
 
 static const char * const describe_usage[] = {
@@ -36,7 +36,6 @@ static const char *diff_index_args[] = {
diff-index, --quiet, HEAD, --, NULL
 };
 
-
 struct commit_name {
struct commit_name *next;
unsigned char peeled[20];
@@ -46,6 +45,7 @@ struct commit_name {
unsigned char sha1[20];
char *path;
 };
+
 static const char *prio_names[] = {
head, lightweight, annotated,
 };
@@ -488,9 +488,8 @@ int cmd_describe(int argc, const char **argv, const char 
*prefix)
} else if (dirty) {
die(_(--dirty is incompatible with commit-ishes));
} else {
-   while (argc--  0) {
+   while (argc--  0)
describe(*argv++, argc == 0);
-   }
}
return 0;
 }
-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/16] branch: trivial style fix

2013-10-31 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 builtin/branch.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/builtin/branch.c b/builtin/branch.c
index ad0f86d..5696cf0 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -975,9 +975,8 @@ int cmd_branch(int argc, const char **argv, const char 
*prefix)
die(_(no such branch '%s'), argv[0]);
}
 
-   if (!branch_has_merge_config(branch)) {
+   if (!branch_has_merge_config(branch))
die(_(Branch '%s' has no upstream information), 
branch-name);
-   }
 
strbuf_addf(buf, branch.%s.remote, branch-name);
git_config_set_multivar(buf.buf, NULL, NULL, 1);
-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] t: branch: improve test rollback

2013-10-31 Thread Felipe Contreras
After every test the environment should be as close as to how it was
before as possible.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 t/t3200-branch.sh | 71 +++
 1 file changed, 35 insertions(+), 36 deletions(-)

diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 0fe7647..33673e0 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -329,7 +329,7 @@ test_expect_success 'tracking setup fails on non-matching 
refspec' '
 '
 
 test_expect_success 'test tracking setup via config' '
-   git config branch.autosetupmerge true 
+   test_config branch.autosetupmerge true 
git config remote.local.url . 
git config remote.local.fetch refs/heads/*:refs/remotes/local/* 
(git show-ref -q refs/remotes/local/master || git fetch local) 
@@ -339,20 +339,18 @@ test_expect_success 'test tracking setup via config' '
 '
 
 test_expect_success 'test overriding tracking setup via --no-track' '
-   git config branch.autosetupmerge true 
+   test_config branch.autosetupmerge true 
git config remote.local.url . 
git config remote.local.fetch refs/heads/*:refs/remotes/local/* 
(git show-ref -q refs/remotes/local/master || git fetch local) 
git branch --no-track my2 local/master 
-   git config branch.autosetupmerge false 
! test $(git config branch.my2.remote) = local 
! test $(git config branch.my2.merge) = refs/heads/master
 '
 
 test_expect_success 'no tracking without .fetch entries' '
-   git config branch.autosetupmerge true 
+   test_config branch.autosetupmerge true 
git branch my6 s 
-   git config branch.autosetupmerge false 
test -z $(git config branch.my6.remote) 
test -z $(git config branch.my6.merge)
 '
@@ -387,9 +385,8 @@ test_expect_success 'test --track without .fetch entries' '
 '
 
 test_expect_success 'branch from non-branch HEAD w/autosetupmerge=always' '
-   git config branch.autosetupmerge always 
-   git branch my9 HEAD^ 
-   git config branch.autosetupmerge false
+   test_config branch.autosetupmerge always 
+   git branch my9 HEAD^
 '
 
 test_expect_success 'branch from non-branch HEAD w/--track causes failure' '
@@ -406,9 +403,9 @@ test_expect_success '--set-upstream-to fails on multiple 
branches' '
 '
 
 test_expect_success '--set-upstream-to fails on detached HEAD' '
+   test_when_finished git checkout - 
git checkout HEAD^{} 
-   test_must_fail git branch --set-upstream-to master 
-   git checkout -
+   test_must_fail git branch --set-upstream-to master
 '
 
 test_expect_success '--set-upstream-to fails on a missing dst branch' '
@@ -460,9 +457,9 @@ test_expect_success '--unset-upstream should fail on 
multiple branches' '
 '
 
 test_expect_success '--unset-upstream should fail on detached HEAD' '
+   test_when_finished git checkout - 
git checkout HEAD^{} 
-   test_must_fail git branch --unset-upstream 
-   git checkout -
+   test_must_fail git branch --unset-upstream
 '
 
 test_expect_success 'test --unset-upstream on a particular branch' '
@@ -541,7 +538,8 @@ test_expect_success 'checkout -b with -l makes reflog when 
core.logAllRefUpdates
 '
 
 test_expect_success 'avoid ambiguous track' '
-   git config branch.autosetupmerge true 
+   test_when_finished git remote rm ambi1  git remote rm ambi2 
+   test_config branch.autosetupmerge true 
git config remote.ambi1.url lalala 
git config remote.ambi1.fetch refs/heads/lalala:refs/heads/master 
git config remote.ambi2.url lilili 
@@ -553,7 +551,7 @@ test_expect_success 'avoid ambiguous track' '
 test_expect_success 'autosetuprebase local on a tracked local branch' '
git config remote.local.url . 
git config remote.local.fetch refs/heads/*:refs/remotes/local/* 
-   git config branch.autosetuprebase local 
+   test_config branch.autosetuprebase local 
(git show-ref -q refs/remotes/local/o || git fetch local) 
git branch mybase 
git branch --track myr1 mybase 
@@ -565,7 +563,7 @@ test_expect_success 'autosetuprebase local on a tracked 
local branch' '
 test_expect_success 'autosetuprebase always on a tracked local branch' '
git config remote.local.url . 
git config remote.local.fetch refs/heads/*:refs/remotes/local/* 
-   git config branch.autosetuprebase always 
+   test_config branch.autosetuprebase always 
(git show-ref -q refs/remotes/local/o || git fetch local) 
git branch mybase2 
git branch --track myr2 mybase 
@@ -577,7 +575,7 @@ test_expect_success 'autosetuprebase always on a tracked 
local branch' '
 test_expect_success 'autosetuprebase remote on a tracked local branch' '
git config remote.local.url . 
git config remote.local.fetch refs/heads/*:refs/remotes/local/* 
-   git config branch.autosetuprebase remote 
+   

[PATCH v5 09/10] fast-export: add support to delete refs

2013-10-31 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 builtin/fast-export.c  | 14 ++
 t/t9350-fast-export.sh | 11 +++
 2 files changed, 25 insertions(+)

diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index b6f623e..8ed41b4 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -673,6 +673,19 @@ static void import_marks(char *input_file)
fclose(f);
 }
 
+static void handle_deletes(void)
+{
+   int i;
+   for (i = 0; i  refspecs_nr; i++) {
+   struct refspec *refspec = refspecs[i];
+   if (*refspec-src)
+   continue;
+
+   printf(reset %s\nfrom %s\n\n,
+   refspec-dst, sha1_to_hex(null_sha1));
+   }
+}
+
 int cmd_fast_export(int argc, const char **argv, const char *prefix)
 {
struct rev_info revs;
@@ -762,6 +775,7 @@ int cmd_fast_export(int argc, const char **argv, const char 
*prefix)
}
 
handle_tags_and_duplicates();
+   handle_deletes();
 
if (export_filename  lastimportid != last_idnum)
export_marks(export_filename);
diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh
index dcf..ea6c96c 100755
--- a/t/t9350-fast-export.sh
+++ b/t/t9350-fast-export.sh
@@ -511,4 +511,15 @@ test_expect_success 'use refspec' '
test_cmp expected actual
 '
 
+test_expect_success 'delete refspec' '
+   git branch to-delete 
+   git fast-export --refspec :refs/heads/to-delete to-delete ^to-delete  
actual 
+   cat  expected -EOF 
+   reset refs/heads/to-delete
+   from 
+
+   EOF
+   test_cmp expected actual
+'
+
 test_done
-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 08/10] fast-import: add support to delete refs

2013-10-31 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 Documentation/git-fast-import.txt |  3 +++
 fast-import.c | 13 ++---
 t/t9300-fast-import.sh| 18 ++
 3 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/Documentation/git-fast-import.txt 
b/Documentation/git-fast-import.txt
index 73f9806..c49ede4 100644
--- a/Documentation/git-fast-import.txt
+++ b/Documentation/git-fast-import.txt
@@ -483,6 +483,9 @@ Marks must be declared (via `mark`) before they can be used.
 * Any valid Git SHA-1 expression that resolves to a commit.  See
   ``SPECIFYING REVISIONS'' in linkgit:gitrevisions[7] for details.
 
+* The special null SHA-1 (40 zeros) specifices that the branch is to be
+  removed.
+
 The special case of restarting an incremental import from the
 current branch value should be written as:
 
diff --git a/fast-import.c b/fast-import.c
index f4d9969..fdce0b7 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -248,6 +248,7 @@ struct branch {
uintmax_t last_commit;
uintmax_t num_notes;
unsigned active : 1;
+   unsigned delete : 1;
unsigned pack_id : PACK_ID_BITS;
unsigned char sha1[20];
 };
@@ -1690,10 +1691,13 @@ static int update_branch(struct branch *b)
struct ref_lock *lock;
unsigned char old_sha1[20];
 
-   if (is_null_sha1(b-sha1))
-   return 0;
if (read_ref(b-name, old_sha1))
hashclr(old_sha1);
+   if (is_null_sha1(b-sha1)) {
+   if (b-delete)
+   delete_ref(b-name, old_sha1, 0);
+   return 0;
+   }
lock = lock_any_ref_for_update(b-name, old_sha1, 0, NULL);
if (!lock)
return error(Unable to lock %s, b-name);
@@ -2620,8 +2624,11 @@ static int parse_from(struct branch *b)
free(buf);
} else
parse_from_existing(b);
-   } else if (!get_sha1(from, b-sha1))
+   } else if (!get_sha1(from, b-sha1)) {
parse_from_existing(b);
+   if (is_null_sha1(b-sha1))
+   b-delete = 1;
+   }
else
die(Invalid ref name or SHA1 expression: %s, from);
 
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 88fc407..f453388 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -2999,4 +2999,22 @@ test_expect_success 'T: ls root tree' '
test_cmp expect actual
 '
 
+test_expect_success 'T: delete branch' '
+   git branch to-delete 
+   git fast-import -EOF 
+   reset refs/heads/to-delete
+   from 
+   EOF
+   test_must_fail git rev-parse --verify refs/heads/to-delete
+'
+
+test_expect_success 'T: empty reset doesnt delete branch' '
+   git branch not-to-delete 
+   git fast-import -EOF 
+   reset refs/heads/not-to-delete
+   EOF
+   git show-ref 
+   git rev-parse --verify refs/heads/not-to-delete
+'
+
 test_done
-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 05/10] fast-export: improve argument parsing

2013-10-31 Thread Felipe Contreras
We don't want to pass arguments specific to fast-export to
setup_revisions.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 builtin/fast-export.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 78250ea..eea5b8c 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -701,8 +701,9 @@ int cmd_fast_export(int argc, const char **argv, const char 
*prefix)
revs.topo_order = 1;
revs.show_source = 1;
revs.rewrite_parents = 1;
+   argc = parse_options(argc, argv, prefix, options, fast_export_usage,
+   PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN);
argc = setup_revisions(argc, argv, revs, NULL);
-   argc = parse_options(argc, argv, prefix, options, fast_export_usage, 0);
if (argc  1)
usage_with_options (fast_export_usage, options);
 
-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 06/10] fast-export: add new --refspec option

2013-10-31 Thread Felipe Contreras
So that we can convert the exported ref names.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 Documentation/git-fast-export.txt |  4 
 builtin/fast-export.c | 30 ++
 t/t9350-fast-export.sh|  7 +++
 3 files changed, 41 insertions(+)

diff --git a/Documentation/git-fast-export.txt 
b/Documentation/git-fast-export.txt
index 85f1f30..221506b 100644
--- a/Documentation/git-fast-export.txt
+++ b/Documentation/git-fast-export.txt
@@ -105,6 +105,10 @@ marks the same across runs.
in the commit (as opposed to just listing the files which are
different from the commit's first parent).
 
+--refspec::
+   Apply the specified refspec to each ref exported. Multiple of them can
+   be specified.
+
 [git-rev-list-args...]::
A list of arguments, acceptable to 'git rev-parse' and
'git rev-list', that specifies the specific objects and references
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index eea5b8c..b6f623e 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -17,6 +17,7 @@
 #include utf8.h
 #include parse-options.h
 #include quote.h
+#include remote.h
 
 static const char *fast_export_usage[] = {
N_(git fast-export [rev-list-opts]),
@@ -31,6 +32,8 @@ static int use_done_feature;
 static int no_data;
 static int full_tree;
 static struct string_list extra_refs = STRING_LIST_INIT_NODUP;
+static struct refspec *refspecs;
+static int refspecs_nr;
 
 static int parse_opt_signed_tag_mode(const struct option *opt,
 const char *arg, int unset)
@@ -525,6 +528,15 @@ static void get_tags_and_duplicates(struct 
rev_cmdline_info *info)
if (dwim_ref(e-name, strlen(e-name), sha1, full_name) != 1)
continue;
 
+   if (refspecs) {
+   char *private;
+   private = apply_refspecs(refspecs, refspecs_nr, 
full_name);
+   if (private) {
+   free(full_name);
+   full_name = private;
+   }
+   }
+
commit = get_commit(e, full_name);
if (!commit) {
warning(%s: Unexpected object of type %s, skipping.,
@@ -668,6 +680,7 @@ int cmd_fast_export(int argc, const char **argv, const char 
*prefix)
struct commit *commit;
char *export_filename = NULL, *import_filename = NULL;
uint32_t lastimportid;
+   struct string_list refspecs_list = STRING_LIST_INIT_NODUP;
struct option options[] = {
OPT_INTEGER(0, progress, progress,
N_(show progress after n objects)),
@@ -688,6 +701,8 @@ int cmd_fast_export(int argc, const char **argv, const char 
*prefix)
OPT_BOOL(0, use-done-feature, use_done_feature,
 N_(Use the done feature to terminate the 
stream)),
OPT_BOOL(0, no-data, no_data, N_(Skip output of blob 
data)),
+   OPT_STRING_LIST(0, refspec, refspecs_list, N_(refspec),
+N_(Apply refspec to exported refs)),
OPT_END()
};
 
@@ -707,6 +722,19 @@ int cmd_fast_export(int argc, const char **argv, const 
char *prefix)
if (argc  1)
usage_with_options (fast_export_usage, options);
 
+   if (refspecs_list.nr) {
+   const char *refspecs_str[refspecs_list.nr];
+   int i;
+
+   for (i = 0; i  refspecs_list.nr; i++)
+   refspecs_str[i] = refspecs_list.items[i].string;
+
+   refspecs_nr = refspecs_list.nr;
+   refspecs = parse_fetch_refspec(refspecs_nr, refspecs_str);
+
+   string_list_clear(refspecs_list, 1);
+   }
+
if (use_done_feature)
printf(feature done\n);
 
@@ -741,5 +769,7 @@ int cmd_fast_export(int argc, const char **argv, const char 
*prefix)
if (use_done_feature)
printf(done\n);
 
+   free_refspec(refspecs_nr, refspecs);
+
return 0;
 }
diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh
index 34c2d8f..dcf 100755
--- a/t/t9350-fast-export.sh
+++ b/t/t9350-fast-export.sh
@@ -504,4 +504,11 @@ test_expect_success 'refs are updated even if no commits 
need to be exported' '
test_cmp expected actual
 '
 
+test_expect_success 'use refspec' '
+   git fast-export --refspec refs/heads/master:refs/heads/foobar master | \
+   grep ^commit  | sort | uniq  actual 
+   echo commit refs/heads/foobar  expected 
+   test_cmp expected actual
+'
+
 test_done
-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 03/10] transport-helper: add 'force' to 'export' helpers

2013-10-31 Thread Felipe Contreras
Otherwise they cannot know when to force the push or not (other than
hacks).

Tests-by: Richard Hansen rhan...@bbn.com
Documentation-by: Richard Hansen rhan...@bbn.com
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 Documentation/gitremote-helpers.txt |  4 
 git-remote-testgit.sh   | 16 
 t/t5801-remote-helpers.sh   | 13 +
 transport-helper.c  |  5 +
 4 files changed, 38 insertions(+)

diff --git a/Documentation/gitremote-helpers.txt 
b/Documentation/gitremote-helpers.txt
index f1f4ca9..e75699c 100644
--- a/Documentation/gitremote-helpers.txt
+++ b/Documentation/gitremote-helpers.txt
@@ -437,6 +437,10 @@ set by Git if the remote helper has the 'option' 
capability.
 'option check-connectivity' \{'true'|'false'\}::
Request the helper to check connectivity of a clone.
 
+'option force' \{'true'|'false'\}::
+   Request the helper to perform a force update.  Defaults to
+   'false'.
+
 SEE ALSO
 
 linkgit:git-remote[1]
diff --git a/git-remote-testgit.sh b/git-remote-testgit.sh
index 6d2f282..716aa4c 100755
--- a/git-remote-testgit.sh
+++ b/git-remote-testgit.sh
@@ -39,6 +39,7 @@ do
fi
test -n $GIT_REMOTE_TESTGIT_SIGNED_TAGS  echo signed-tags
test -n $GIT_REMOTE_TESTGIT_NO_PRIVATE_UPDATE  echo 
no-private-update
+   echo 'option'
echo
;;
list)
@@ -93,6 +94,7 @@ do
before=$(git for-each-ref --format=' %(refname) %(objectname) ')
 
git fast-import \
+   ${force:+--force} \
${testgitmarks:+--import-marks=$testgitmarks} \
${testgitmarks:+--export-marks=$testgitmarks} \
--quiet
@@ -115,6 +117,20 @@ do
 
echo
;;
+   option\ *)
+   read cmd opt val -EOF
+   $line
+   EOF
+   case $opt in
+   force)
+   test $val = true  force=true || force=
+   echo ok
+   ;;
+   *)
+   echo unsupported
+   ;;
+   esac
+   ;;
'')
exit
;;
diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index 613f69a..c33cc25 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -94,6 +94,19 @@ test_expect_failure 'push new branch with old:new refspec' '
compare_refs local HEAD server refs/heads/new-refspec
 '
 
+test_expect_success 'forced push' '
+   (cd local 
+   git checkout -b force-test 
+   echo content  file 
+   git commit -a -m eight 
+   git push origin force-test 
+   echo content  file 
+   git commit -a --amend -m eight-modified 
+   git push --force origin force-test
+   ) 
+   compare_refs local refs/heads/force-test server refs/heads/force-test
+'
+
 test_expect_success 'cloning without refspec' '
GIT_REMOTE_TESTGIT_REFSPEC= \
git clone testgit::${PWD}/server local2 2error 
diff --git a/transport-helper.c b/transport-helper.c
index d05fc7c..ed238e5 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -854,6 +854,11 @@ static int push_refs_with_export(struct transport 
*transport,
die(helper %s does not support dry-run, data-name);
}
 
+   if (flags  TRANSPORT_PUSH_FORCE) {
+   if (set_helper_option(transport, force, true) != 0)
+   die(helper %s does not support 'force', data-name);
+   }
+
helper = get_helper(transport);
 
write_constant(helper-in, export\n);
-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 02/10] transport-helper: don't update refs in dry-run

2013-10-31 Thread Felipe Contreras
The remote helper namespace should not be updated.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 transport-helper.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/transport-helper.c b/transport-helper.c
index 985eeea..d05fc7c 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -727,7 +727,8 @@ static int push_update_ref_status(struct strbuf *buf,
 }
 
 static void push_update_refs_status(struct helper_data *data,
-   struct ref *remote_refs)
+   struct ref *remote_refs,
+   int flags)
 {
struct strbuf buf = STRBUF_INIT;
struct ref *ref = remote_refs;
@@ -741,7 +742,7 @@ static void push_update_refs_status(struct helper_data 
*data,
if (push_update_ref_status(buf, ref, remote_refs))
continue;
 
-   if (!data-refspecs || data-no_private_update)
+   if (flags  TRANSPORT_PUSH_DRY_RUN || !data-refspecs || 
data-no_private_update)
continue;
 
/* propagate back the update to the remote namespace */
@@ -832,7 +833,7 @@ static int push_refs_with_push(struct transport *transport,
sendline(data, buf);
strbuf_release(buf);
 
-   push_update_refs_status(data, remote_refs);
+   push_update_refs_status(data, remote_refs, flags);
return 0;
 }
 
@@ -886,7 +887,7 @@ static int push_refs_with_export(struct transport 
*transport,
 
if (finish_command(exporter))
die(Error while running fast-export);
-   push_update_refs_status(data, remote_refs);
+   push_update_refs_status(data, remote_refs, flags);
return 0;
 }
 
-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 01/10] transport-helper: fix extra lines

2013-10-31 Thread Felipe Contreras
Commit 9c51558 (transport-helper: trivial code shuffle) moved these
lines above, but 99d9ec0 (Merge branch 'fc/transport-helper-no-refspec')
had a wrong merge conflict and readded them.

Reported-by: Richard Hansen rhan...@bbn.com
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 transport-helper.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/transport-helper.c b/transport-helper.c
index b32e2d6..985eeea 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -874,9 +874,6 @@ static int push_refs_with_export(struct transport 
*transport,
}
free(private);
 
-   if (ref-deletion)
-   die(remote-helpers do not support ref deletion);
-
if (ref-peer_ref) {
if (strcmp(ref-peer_ref-name, ref-name))
die(remote-helpers do not support old:new 
syntax);
-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 07/10] transport-helper: add support for old:new refspec

2013-10-31 Thread Felipe Contreras
By using fast-export's new --refspec option.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 t/t5801-remote-helpers.sh |  2 +-
 transport-helper.c| 13 ++---
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index c33cc25..454337e 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -87,7 +87,7 @@ test_expect_success 'push new branch by name' '
compare_refs local HEAD server refs/heads/new-name
 '
 
-test_expect_failure 'push new branch with old:new refspec' '
+test_expect_success 'push new branch with old:new refspec' '
(cd local 
 git push origin new-name:new-refspec
) 
diff --git a/transport-helper.c b/transport-helper.c
index 5aba15c..84ff578 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -849,7 +849,7 @@ static int push_refs_with_export(struct transport 
*transport,
struct ref *ref;
struct child_process *helper, exporter;
struct helper_data *data = transport-data;
-   struct string_list revlist_args = STRING_LIST_INIT_NODUP;
+   struct string_list revlist_args = STRING_LIST_INIT_DUP;
struct strbuf buf = STRBUF_INIT;
 
if (!data-refspecs)
@@ -887,8 +887,13 @@ static int push_refs_with_export(struct transport 
*transport,
free(private);
 
if (ref-peer_ref) {
-   if (strcmp(ref-peer_ref-name, ref-name))
-   die(remote-helpers do not support old:new 
syntax);
+   if (strcmp(ref-name, ref-peer_ref-name)) {
+   struct strbuf buf = STRBUF_INIT;
+   strbuf_addf(buf, %s:%s, ref-peer_ref-name, 
ref-name);
+   string_list_append(revlist_args, --refspec);
+   string_list_append(revlist_args, buf.buf);
+   strbuf_release(buf);
+   }
string_list_append(revlist_args, ref-peer_ref-name);
}
}
@@ -896,6 +901,8 @@ static int push_refs_with_export(struct transport 
*transport,
if (get_exporter(transport, exporter, revlist_args))
die(Couldn't run fast-export);
 
+   string_list_clear(revlist_args, 1);
+
if (finish_command(exporter))
die(Error while running fast-export);
push_update_refs_status(data, remote_refs, flags);
-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 04/10] transport-helper: check for 'forced update' message

2013-10-31 Thread Felipe Contreras
So the remote-helpers can tell us when a forced push was needed.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 transport-helper.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/transport-helper.c b/transport-helper.c
index ed238e5..5aba15c 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -643,7 +643,7 @@ static int push_update_ref_status(struct strbuf *buf,
   struct ref *remote_refs)
 {
char *refname, *msg;
-   int status;
+   int status, forced = 0;
 
if (!prefixcmp(buf-buf, ok )) {
status = REF_STATUS_OK;
@@ -701,6 +701,11 @@ static int push_update_ref_status(struct strbuf *buf,
free(msg);
msg = NULL;
}
+   else if (!strcmp(msg, forced update)) {
+   forced = 1;
+   free(msg);
+   msg = NULL;
+   }
}
 
if (*ref)
@@ -722,6 +727,7 @@ static int push_update_ref_status(struct strbuf *buf,
}
 
(*ref)-status = status;
+   (*ref)-forced_update = forced;
(*ref)-remote_status = msg;
return !(status == REF_STATUS_OK);
 }
-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 00/10] transport-helper: updates

2013-10-31 Thread Felipe Contreras
Hi,

Here are the patches that allow transport helpers to be completely transparent;
renaming branches, deleting them, custom refspecs, --force, --dry-run,
reporting forced update, everything works.

Some of these were were sent before and rejected without a reason, but here
they are again in case anybody is interested.

Diff from v3:

diff --git a/Documentation/gitremote-helpers.txt 
b/Documentation/gitremote-helpers.txt
index f1f4ca9..e75699c 100644
--- a/Documentation/gitremote-helpers.txt
+++ b/Documentation/gitremote-helpers.txt
@@ -437,6 +437,10 @@ set by Git if the remote helper has the 'option' 
capability.
 'option check-connectivity' \{'true'|'false'\}::
Request the helper to check connectivity of a clone.
 
+'option force' \{'true'|'false'\}::
+   Request the helper to perform a force update.  Defaults to
+   'false'.
+
 SEE ALSO
 
 linkgit:git-remote[1]
diff --git a/git-remote-testgit.sh b/git-remote-testgit.sh
index 6d2f282..716aa4c 100755
--- a/git-remote-testgit.sh
+++ b/git-remote-testgit.sh
@@ -39,6 +39,7 @@ do
fi
test -n $GIT_REMOTE_TESTGIT_SIGNED_TAGS  echo signed-tags
test -n $GIT_REMOTE_TESTGIT_NO_PRIVATE_UPDATE  echo 
no-private-update
+   echo 'option'
echo
;;
list)
@@ -93,6 +94,7 @@ do
before=$(git for-each-ref --format=' %(refname) %(objectname) ')
 
git fast-import \
+   ${force:+--force} \
${testgitmarks:+--import-marks=$testgitmarks} \
${testgitmarks:+--export-marks=$testgitmarks} \
--quiet
@@ -115,6 +117,20 @@ do
 
echo
;;
+   option\ *)
+   read cmd opt val -EOF
+   $line
+   EOF
+   case $opt in
+   force)
+   test $val = true  force=true || force=
+   echo ok
+   ;;
+   *)
+   echo unsupported
+   ;;
+   esac
+   ;;
'')
exit
;;
diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index be543c0..c667965 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -102,6 +102,19 @@ test_expect_success 'push delete branch' '
 rev-parse --verify refs/heads/new-name
 '
 
+test_expect_success 'forced push' '
+   (cd local 
+   git checkout -b force-test 
+   echo content  file 
+   git commit -a -m eight 
+   git push origin force-test 
+   echo content  file 
+   git commit -a --amend -m eight-modified 
+   git push --force origin force-test
+   ) 
+   compare_refs local refs/heads/force-test server refs/heads/force-test
+'
+
 test_expect_success 'cloning without refspec' '
GIT_REMOTE_TESTGIT_REFSPEC= \
git clone testgit::${PWD}/server local2 2error 

Felipe Contreras (10):
  transport-helper: fix extra lines
  transport-helper: don't update refs in dry-run
  transport-helper: add 'force' to 'export' helpers
  transport-helper: check for 'forced update' message
  fast-export: improve argument parsing
  fast-export: add new --refspec option
  transport-helper: add support for old:new refspec
  fast-import: add support to delete refs
  fast-export: add support to delete refs
  transport-helper: add support to delete branches

 Documentation/git-fast-export.txt   |  4 
 Documentation/git-fast-import.txt   |  3 +++
 Documentation/gitremote-helpers.txt |  4 
 builtin/fast-export.c   | 47 -
 fast-import.c   | 13 +++---
 git-remote-testgit.sh   | 16 +
 t/t5801-remote-helpers.sh   | 23 +-
 t/t9300-fast-import.sh  | 18 ++
 t/t9350-fast-export.sh  | 18 ++
 transport-helper.c  | 47 +
 10 files changed, 173 insertions(+), 20 deletions(-)

-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 10/10] transport-helper: add support to delete branches

2013-10-31 Thread Felipe Contreras
For remote-helpers that use 'export' to push.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 t/t5801-remote-helpers.sh |  8 
 transport-helper.c| 11 ++-
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index 454337e..c667965 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -94,6 +94,14 @@ test_expect_success 'push new branch with old:new refspec' '
compare_refs local HEAD server refs/heads/new-refspec
 '
 
+test_expect_success 'push delete branch' '
+   (cd local 
+git push origin :new-name
+   ) 
+   test_must_fail git --git-dir=server/.git \
+rev-parse --verify refs/heads/new-name
+'
+
 test_expect_success 'forced push' '
(cd local 
git checkout -b force-test 
diff --git a/transport-helper.c b/transport-helper.c
index 84ff578..ef91882 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -875,9 +875,6 @@ static int push_refs_with_export(struct transport 
*transport,
char *private;
unsigned char sha1[20];
 
-   if (ref-deletion)
-   die(remote-helpers do not support ref deletion);
-
private = apply_refspecs(data-refspecs, data-refspec_nr, 
ref-name);
if (private  !get_sha1(private, sha1)) {
strbuf_addf(buf, ^%s, private);
@@ -889,12 +886,16 @@ static int push_refs_with_export(struct transport 
*transport,
if (ref-peer_ref) {
if (strcmp(ref-name, ref-peer_ref-name)) {
struct strbuf buf = STRBUF_INIT;
-   strbuf_addf(buf, %s:%s, ref-peer_ref-name, 
ref-name);
+   if (!ref-deletion)
+   strbuf_addf(buf, %s:%s, 
ref-peer_ref-name, ref-name);
+   else
+   strbuf_addf(buf, :%s, ref-name);
string_list_append(revlist_args, --refspec);
string_list_append(revlist_args, buf.buf);
strbuf_release(buf);
}
-   string_list_append(revlist_args, ref-peer_ref-name);
+   if (!ref-deletion)
+   string_list_append(revlist_args, 
ref-peer_ref-name);
}
}
 
-- 
1.8.4.2+fc1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH (resend) 0/3] Minor f-e-r enhacements

2013-10-31 Thread Ramkumar Ramachandra
Hi,

I've been running git with these patches applied locally for a long
time. Although I've sent them to the list before, they've been
overlooked.

Thanks.

Ramkumar Ramachandra (3):
  for-each-ref: introduce %C(...) for color
  for-each-ref: introduce %(HEAD) asterisk marker
  for-each-ref: introduce %(upstream:track[short])

 Documentation/git-for-each-ref.txt | 14 ++-
 builtin/for-each-ref.c | 75 ++
 2 files changed, 79 insertions(+), 10 deletions(-)

-- 
1.8.5.rc0.3.gb488857

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] for-each-ref: introduce %C(...) for color

2013-10-31 Thread Ramkumar Ramachandra
Enhance 'git for-each-ref' with color formatting options.  You can now
use the following format in for-each-ref:

  %C(green)%(refname:short)%C(reset)

Signed-off-by: Ramkumar Ramachandra artag...@gmail.com
---
 Documentation/git-for-each-ref.txt |  4 +++-
 builtin/for-each-ref.c | 23 +++
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/Documentation/git-for-each-ref.txt 
b/Documentation/git-for-each-ref.txt
index f2e08d1..6fa4464 100644
--- a/Documentation/git-for-each-ref.txt
+++ b/Documentation/git-for-each-ref.txt
@@ -45,7 +45,9 @@ OPTIONS
It also interpolates `%%` to `%`, and `%xx` where `xx`
are hex digits interpolates to character with hex code
`xx`; for example `%00` interpolates to `\0` (NUL),
-   `%09` to `\t` (TAB) and `%0a` to `\n` (LF).
+   `%09` to `\t` (TAB) and `%0a` to `\n` (LF). Additionally,
+   colors can be specified using `%C(...)`, with names
+   described in color.branch.*.
 
 pattern...::
If one or more patterns are given, only refs are shown that
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
index 1d4083c..6da2903 100644
--- a/builtin/for-each-ref.c
+++ b/builtin/for-each-ref.c
@@ -9,6 +9,7 @@
 #include quote.h
 #include parse-options.h
 #include remote.h
+#include color.h
 
 /* Quoting styles */
 #define QUOTE_NONE 0
@@ -155,10 +156,13 @@ static const char *find_next(const char *cp)
while (*cp) {
if (*cp == '%') {
/*
+* %C( is the start of a color;
 * %( is the start of an atom;
 * %% is a quoted per-cent.
 */
-   if (cp[1] == '(')
+   if (cp[1] == 'C'  cp[2] == '(')
+   return cp;
+   else if (cp[1] == '(')
return cp;
else if (cp[1] == '%')
cp++; /* skip over two % */
@@ -180,8 +184,11 @@ static int verify_format(const char *format)
const char *ep = strchr(sp, ')');
if (!ep)
return error(malformed format string %s, sp);
-   /* sp points at %( and ep points at the closing ) */
-   parse_atom(sp + 2, ep);
+   /* Ignore color specifications: %C(
+* sp points at %( and ep points at the closing )
+*/
+   if (prefixcmp(sp, %C())
+   parse_atom(sp + 2, ep);
cp = ep + 1;
}
return 0;
@@ -933,12 +940,20 @@ static void emit(const char *cp, const char *ep)
 static void show_ref(struct refinfo *info, const char *format, int quote_style)
 {
const char *cp, *sp, *ep;
+   char color[COLOR_MAXLEN] = ;
 
for (cp = format; *cp  (sp = find_next(cp)); cp = ep + 1) {
ep = strchr(sp, ')');
if (cp  sp)
emit(cp, sp);
-   print_value(info, parse_atom(sp + 2, ep), quote_style);
+
+   /* Do we have a color specification? */
+   if (!prefixcmp(sp, %C())
+   color_parse_mem(sp + 3, ep - sp - 3, --format, color);
+   else {
+   printf(%s, color);
+   print_value(info, parse_atom(sp + 2, ep), quote_style);
+   }
}
if (*cp) {
sp = cp + strlen(cp);
-- 
1.8.5.rc0.3.gb488857

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] for-each-ref: introduce %(HEAD) asterisk marker

2013-10-31 Thread Ramkumar Ramachandra
'git branch' shows which branch you are currently on with an '*', but
'git for-each-ref' misses this feature.  So, extend its format with
%(HEAD) for the same effect.

Now you can use the following format in for-each-ref:

  %C(red)%(HEAD)%C(reset) %(refname:short)

to display a red asterisk next to the current ref.

Signed-off-by: Ramkumar Ramachandra artag...@gmail.com
---
 Documentation/git-for-each-ref.txt |  4 
 builtin/for-each-ref.c | 13 +++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-for-each-ref.txt 
b/Documentation/git-for-each-ref.txt
index 6fa4464..bb9c4c1 100644
--- a/Documentation/git-for-each-ref.txt
+++ b/Documentation/git-for-each-ref.txt
@@ -95,6 +95,10 @@ upstream::
from the displayed ref. Respects `:short` in the same way as
`refname` above.
 
+HEAD::
+   Used to indicate the currently checked out branch.  Is '*' if
+   HEAD points to the current ref, and ' ' otherwise.
+
 In addition to the above, for commit and tag objects, the header
 field names (`tree`, `parent`, `object`, `type`, and `tag`) can
 be used to specify the value in the header field.
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
index 6da2903..b841545 100644
--- a/builtin/for-each-ref.c
+++ b/builtin/for-each-ref.c
@@ -76,6 +76,7 @@ static struct {
{ upstream },
{ symref },
{ flag },
+   { HEAD },
 };
 
 /*
@@ -682,8 +683,16 @@ static void populate_value(struct refinfo *ref)
v-s = xstrdup(buf + 1);
}
continue;
-   }
-   else
+   } else if (!strcmp(name, HEAD)) {
+   const char *head;
+   unsigned char sha1[20];
+   head = resolve_ref_unsafe(HEAD, sha1, 1, NULL);
+   if (!strcmp(ref-refname, head))
+   v-s = *;
+   else
+   v-s =  ;
+   continue;
+   } else
continue;
 
formatp = strchr(name, ':');
-- 
1.8.5.rc0.3.gb488857

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] for-each-ref: introduce %(upstream:track[short])

2013-10-31 Thread Ramkumar Ramachandra
Introduce %(upstream:track) to display [ahead M, behind N] and
%(upstream:trackshort) to display =, , , or 
appropriately (inspired by contrib/completion/git-prompt.sh).

Now you can use the following format in for-each-ref:

  %C(green)%(refname:short)%C(reset)%(upstream:trackshort)

to display refs with terse tracking information.

Note that :track and :trackshort only work with upstream, and error
out when used with anything else.

Signed-off-by: Ramkumar Ramachandra artag...@gmail.com
---
 Documentation/git-for-each-ref.txt |  6 +-
 builtin/for-each-ref.c | 39 --
 2 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/Documentation/git-for-each-ref.txt 
b/Documentation/git-for-each-ref.txt
index bb9c4c1..3ef6aa8 100644
--- a/Documentation/git-for-each-ref.txt
+++ b/Documentation/git-for-each-ref.txt
@@ -93,7 +93,11 @@ objectname::
 upstream::
The name of a local ref which can be considered ``upstream''
from the displayed ref. Respects `:short` in the same way as
-   `refname` above.
+   `refname` above.  Additionally respects `:track` to show
+   [ahead N, behind M] and `:trackshort` to show the terse
+   version (like the prompt) , , , or =.  Has no
+   effect if the ref does not have tracking information
+   associated with it.
 
 HEAD::
Used to indicate the currently checked out branch.  Is '*' if
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
index b841545..7d5c174 100644
--- a/builtin/for-each-ref.c
+++ b/builtin/for-each-ref.c
@@ -648,6 +648,7 @@ static void populate_value(struct refinfo *ref)
int deref = 0;
const char *refname;
const char *formatp;
+   struct branch *branch;
 
if (*name == '*') {
deref = 1;
@@ -659,7 +660,6 @@ static void populate_value(struct refinfo *ref)
else if (!prefixcmp(name, symref))
refname = ref-symref ? ref-symref : ;
else if (!prefixcmp(name, upstream)) {
-   struct branch *branch;
/* only local branches may have an upstream */
if (prefixcmp(ref-refname, refs/heads/))
continue;
@@ -686,6 +686,7 @@ static void populate_value(struct refinfo *ref)
} else if (!strcmp(name, HEAD)) {
const char *head;
unsigned char sha1[20];
+
head = resolve_ref_unsafe(HEAD, sha1, 1, NULL);
if (!strcmp(ref-refname, head))
v-s = *;
@@ -698,11 +699,45 @@ static void populate_value(struct refinfo *ref)
formatp = strchr(name, ':');
/* look for short refname format */
if (formatp) {
+   int num_ours, num_theirs;
+
formatp++;
if (!strcmp(formatp, short))
refname = shorten_unambiguous_ref(refname,
  warn_ambiguous_refs);
-   else
+   else if (!strcmp(formatp, track) 
+   !prefixcmp(name, upstream)) {
+   char buf[40];
+
+   stat_tracking_info(branch, num_ours, 
num_theirs);
+   if (!num_ours  !num_theirs)
+   v-s = ;
+   else if (!num_ours) {
+   sprintf(buf, [behind %d], num_theirs);
+   v-s = xstrdup(buf);
+   } else if (!num_theirs) {
+   sprintf(buf, [ahead %d], num_ours);
+   v-s = xstrdup(buf);
+   } else {
+   sprintf(buf, [ahead %d, behind %d],
+   num_ours, num_theirs);
+   v-s = xstrdup(buf);
+   }
+   continue;
+   } else if (!strcmp(formatp, trackshort) 
+   !prefixcmp(name, upstream)) {
+
+   stat_tracking_info(branch, num_ours, 
num_theirs);
+   if (!num_ours  !num_theirs)
+   v-s = =;
+   else if (!num_ours)
+   v-s = ;
+   else if (!num_theirs)
+   v-s = ;
+   else
+   v-s = ;
+   continue;
+   } else
 

Re: Show patch in gitk --first-parent ?

2013-10-31 Thread Karl Wiberg
On Wed, Oct 30, 2013 at 6:55 PM, Andreas Schwab sch...@linux-m68k.org wrote:
 While not automatic, you can right click on the parent and select
 Diff this-selected.

And there's also the option to mark a commit, and diff this with
marked. Thanks, that's just what I needed (although as you say, it
isn't automatic).

-- 
Karl Wiberg, k...@treskal.com
   subrabbit.wordpress.com
   www.treskal.com/kalle
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


sticked - stuck

2013-10-31 Thread Nicolas Vigier
Here is a patch to replace the word 'sticked' with 'stuck' in existing
documentation. And the patch for nv/parseopt-opt-arg changed to use the
word 'stuck' too.

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] rev-parse --parseopt: add the --stuck-long mode

2013-10-31 Thread Nicolas Vigier
Add the --stuck-long option to output the options in their long form
if available, and with their arguments stuck.

Contrary to the default form (non stuck arguments and short options),
this can be parsed unambiguously when using options with optional
arguments :

 - in the non stuck form, when an option is taking an optional argument
   you cannot know if the next argument is its optional argument, or the
   next option.

 - the long options form allows to differentiate between an empty argument
   '--option=' and an unset argument '--option', which is not possible
   with short options.

Signed-off-by: Nicolas Vigier bo...@mars-attacks.org
---
 Documentation/git-rev-parse.txt |  8 +++-
 builtin/rev-parse.c | 11 +--
 t/t1502-rev-parse-parseopt.sh   | 42 ++---
 3 files changed, 55 insertions(+), 6 deletions(-)

diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt
index d068a653778d..a436b24cc406 100644
--- a/Documentation/git-rev-parse.txt
+++ b/Documentation/git-rev-parse.txt
@@ -50,6 +50,10 @@ Options for --parseopt
the first non-option argument.  This can be used to parse sub-commands
that take options themselves.
 
+--stuck-long::
+   Only meaningful in `--parseopt` mode. Output the options in their
+   long form if available, and with their arguments stuck.
+
 Options for Filtering
 ~
 
@@ -285,7 +289,9 @@ Each line of options has this format:
`flags` are of `*`, `=`, `?` or `!`.
* Use `=` if the option takes an argument.
 
-   * Use `?` to mean that the option is optional (though its use is 
discouraged).
+   * Use `?` to mean that the option takes an optional argument. You
+ probably want to use the `--stuck-long` mode to be able to
+ unambiguously parse the optional argument.
 
* Use `*` to mean that this option should not be listed in the usage
  generated for the `-h` argument. It's shown for `--help-all` as
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index c76b89dc5bcc..3e8c4cce060e 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -30,6 +30,8 @@ static int abbrev_ref;
 static int abbrev_ref_strict;
 static int output_sq;
 
+static int stuck_long;
+
 /*
  * Some arguments are relevant revision arguments,
  * others are about output format or other details.
@@ -320,12 +322,15 @@ static int parseopt_dump(const struct option *o, const 
char *arg, int unset)
struct strbuf *parsed = o-value;
if (unset)
strbuf_addf(parsed,  --no-%s, o-long_name);
-   else if (o-short_name)
+   else if (o-short_name  (o-long_name == NULL || !stuck_long))
strbuf_addf(parsed,  -%c, o-short_name);
else
strbuf_addf(parsed,  --%s, o-long_name);
if (arg) {
-   strbuf_addch(parsed, ' ');
+   if (!stuck_long)
+   strbuf_addch(parsed, ' ');
+   else if (o-long_name)
+   strbuf_addch(parsed, '=');
sq_quote_buf(parsed, arg);
}
return 0;
@@ -351,6 +356,8 @@ static int cmd_parseopt(int argc, const char **argv, const 
char *prefix)
OPT_BOOL(0, stop-at-non-option, stop_at_non_option,
N_(stop parsing after the 
   first non-option argument)),
+   OPT_BOOL(0, stuck-long, stuck_long,
+   N_(output in stuck long form)),
OPT_END(),
};
 
diff --git a/t/t1502-rev-parse-parseopt.sh b/t/t1502-rev-parse-parseopt.sh
index 13c88c9aae7f..83b1300cef91 100755
--- a/t/t1502-rev-parse-parseopt.sh
+++ b/t/t1502-rev-parse-parseopt.sh
@@ -12,9 +12,11 @@ usage: some-command [options] args...
 -h, --helpshow the help
 --foo some nifty option --foo
 --bar ... some cool option --bar with an argument
+-b, --baz a short and long option
 
 An option group Header
 -C[...]   option C with an optional argument
+-d, --data[=...]  short and long option with an optional argument
 
 Extras
 --extra1  line above used to cause a segfault but no longer 
does
@@ -31,9 +33,11 @@ h,helpshow the help
 
 foo   some nifty option --foo
 bar=  some cool option --bar with an argument
+b,baz a short and long option
 
  An option group Header
 C?option C with an optional argument
+d,data?   short and long option with an optional argument
 
 Extras
 extra1line above used to cause a segfault but no longer does
@@ -45,16 +49,16 @@ test_expect_success 'test --parseopt help output' '
 '
 
 cat  expect EOF
-set -- --foo --bar 'ham' -- 'arg'
+set -- --foo --bar 'ham' -b -- 'arg'
 EOF
 
 test_expect_success 'test --parseopt' '
-   git rev-parse --parseopt -- --foo --bar=ham arg  

[PATCH 1/2] Use the word 'stuck' instead of 'sticked'

2013-10-31 Thread Nicolas Vigier
The past participle of 'stick' is 'stuck'.

Signed-off-by: Nicolas Vigier bo...@mars-attacks.org
---
 Documentation/gitcli.txt  | 6 +++---
 Documentation/technical/api-parse-options.txt | 6 +++---
 diff.c| 2 +-
 diff.h| 2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/Documentation/gitcli.txt b/Documentation/gitcli.txt
index 3146413cce0d..c87f0ae88d6c 100644
--- a/Documentation/gitcli.txt
+++ b/Documentation/gitcli.txt
@@ -72,11 +72,11 @@ scripting Git:
  * splitting short options to separate words (prefer `git foo -a -b`
to `git foo -ab`, the latter may not even work).
 
- * when a command line option takes an argument, use the 'sticked' form.  In
+ * when a command line option takes an argument, use the 'stuck' form.  In
other words, write `git foo -oArg` instead of `git foo -o Arg` for short
options, and `git foo --long-opt=Arg` instead of `git foo --long-opt Arg`
for long options.  An option that takes optional option-argument must be
-   written in the 'sticked' form.
+   written in the 'stuck' form.
 
  * when you give a revision parameter to a command, make sure the parameter is
not ambiguous with a name of a file in the work tree.  E.g. do not write
@@ -165,7 +165,7 @@ $ git foo -o Arg
 
 
 However, this is *NOT* allowed for switches with an optional value, where the
-'sticked' form must be used:
+'stuck' form must be used:
 
 $ git describe --abbrev HEAD # correct
 $ git describe --abbrev=10 HEAD  # correct
diff --git a/Documentation/technical/api-parse-options.txt 
b/Documentation/technical/api-parse-options.txt
index 0be2b5159f1b..be50cf4de35c 100644
--- a/Documentation/technical/api-parse-options.txt
+++ b/Documentation/technical/api-parse-options.txt
@@ -29,9 +29,9 @@ that allow to change the behavior of a command.
 
 The parse-options API allows:
 
-* 'sticked' and 'separate form' of options with arguments.
-  `-oArg` is sticked, `-o Arg` is separate form.
-  `--option=Arg` is sticked, `--option Arg` is separate form.
+* 'stuck' and 'separate form' of options with arguments.
+  `-oArg` is stuck, `-o Arg` is separate form.
+  `--option=Arg` is stuck, `--option Arg` is separate form.
 
 * Long options may be 'abbreviated', as long as the abbreviation
   is unambiguous.
diff --git a/diff.c b/diff.c
index e34bf971207f..3950e0191067 100644
--- a/diff.c
+++ b/diff.c
@@ -3394,7 +3394,7 @@ int parse_long_opt(const char *opt, const char **argv,
if (prefixcmp(arg, opt))
return 0;
arg += strlen(opt);
-   if (*arg == '=') { /* sticked form: --option=value */
+   if (*arg == '=') { /* stuck form: --option=value */
*optarg = arg + 1;
return 1;
}
diff --git a/diff.h b/diff.h
index e34232501ee8..1c05b3a6bec6 100644
--- a/diff.h
+++ b/diff.h
@@ -244,7 +244,7 @@ extern struct diff_filepair *diff_unmerge(struct 
diff_options *, const char *pat
 #define DIFF_SETUP_USE_SIZE_CACHE  4
 
 /*
- * Poor man's alternative to parse-option, to allow both sticked form
+ * Poor man's alternative to parse-option, to allow both stuck form
  * (--option=value) and separate form (--option value).
  */
 extern int parse_long_opt(const char *opt, const char **argv,
-- 
1.8.4

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 11/19] pack-objects: use bitmaps when packing objects

2013-10-31 Thread Duy Nguyen
On Thu, Oct 31, 2013 at 3:07 AM, Jeff King p...@peff.net wrote:
 I think there are two cases that we need to consider:

   1. We have a full repo and somebody requests a shallow clone for us.
  We probably do not want to use bitmaps here.  In the series we have
  been testing, shallow clones turned off bitmaps because we do not
  use the internal rev_list. But as of cdab485 (upload-pack: delegate
  rev walking in shallow fetch to pack-objects), that distinction
  doesn't hold. I think we can check the use of --shallow-file
  instead of explicitly turning off bitmaps there.

There's an (non-existing yet) case 1': somebody requests a clone and
the source clone is already shallow. is_repository_shallow() could
catch both cases.

   2. We have a shallow clone that wants to repack. We probably want to
  turn off bitmap writing here. I don't think that grafts actually
  matter here, because pack-objects should always be looking at the
  true graph. It would mean that using git rev-list
  --use-bitmap-index does not respect the grafts, and we should
  probably disable it in that case (and ditto for replacements).

Right. I forgot that the repo must be complete before it's grafted.
-- 
Duy
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Fix '\%o' for printf from coreutils

2013-10-31 Thread Kacper Kornet
The printf utility provided by coreutils when interpreting '\%o' format
does not recognize %o as formatting directive. For example
printf '\%o 0 returns \%o and warning: ignoring excess arguments,
starting with ‘0’, which results in failed tests in
t5309-pack-delta-cycles.sh. In most shells the test ends with success as
the printf is a builtin utility.

Fix it by using '\\%o' which is interpreted consistently in all versions
of printf.

Signed-off-by: Kacper Kornet drae...@pld-linux.org
---

I've found it while testing v1.8.5-rc0 with mksh which does not
provide a builtin printf.

Kacper

 t/lib-pack.sh | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/t/lib-pack.sh b/t/lib-pack.sh
index 7e8685b..b96e125 100644
--- a/t/lib-pack.sh
+++ b/t/lib-pack.sh
@@ -12,10 +12,10 @@
 # Print the big-endian 4-byte octal representation of $1
 uint32_octal () {
n=$1
-   printf '\%o' $(($n / 16777216)); n=$((n % 16777216))
-   printf '\%o' $(($n /65536)); n=$((n %65536))
-   printf '\%o' $(($n /  256)); n=$((n %  256))
-   printf '\%o' $(($n   ));
+   printf '\\%o' $(($n / 16777216)); n=$((n % 16777216))
+   printf '\\%o' $(($n /65536)); n=$((n %65536))
+   printf '\\%o' $(($n /  256)); n=$((n %  256))
+   printf '\\%o' $(($n   ));
 }
 
 # Print the big-endian 4-byte binary representation of $1
-- 
1.8.4.2

-- 
  Kacper Kornet
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: htonll, ntohll

2013-10-31 Thread Torsten Bögershausen
On 2013-10-30 22.07, Ramsay Jones wrote:
 On 30/10/13 20:30, Torsten Bögershausen wrote:
 On 2013-10-30 20.06, Ramsay Jones wrote:
 On 30/10/13 17:14, Torsten Bögershausen wrote:
 On 2013-10-30 18.01, Vicent Martí wrote:
 On Wed, Oct 30, 2013 at 5:51 PM, Torsten Bögershausen tbo...@web.de 
 wrote:
 There is a name clash under cygwin 1.7 (1.5 is OK)
 The following first aid hot fix works for me:
 /Torsten

 If Cygwin declares its own bswap_64, wouldn't it be better to use it
 instead of overwriting it with our own?
 Yes,
 this will be part of a longer patch.
 I found that some systems have something like this:

 #define htobe64(x) bswap_64(x)
 And bswap_64 is a function, so we can not detect it by asking
 #ifdef bswap_64
 ..
 #endif


 But we can use
 #ifdef htobe64
 ...
 #endif
 and this will be part of a bigger patch.

 And, in general, we should avoid to introduce functions which may have a
 name clash.
 Using the git_ prefix for function names is a good practice.
 So in order to unbrake the compilation error under cygwin 17,
 the hotfix can be used.

 heh, my patch (given below) took a different approach, but 

 ATB,
 Ramsay Jones

 -- 8 --
 Subject: [PATCH] compat/bswap.h: Fix redefinition of bswap_64 error on 
 cygwin
 MIME-Version: 1.0
 Content-Type: text/plain; charset=UTF-8
 Content-Transfer-Encoding: 8bit

 Since commit 452e0f20 (compat: add endianness helpers, 24-10-2013)
 the cygwin build has failed like so:

 GIT_VERSION = 1.8.4.1.804.g1f3748b
 * new build flags
 CC credential-store.o
 In file included from git-compat-util.h:305:0,
  from cache.h:4,
  from credential-store.c:1:
 compat/bswap.h:67:24: error: redefinition of 'bswap_64'
 In file included from /usr/include/endian.h:32:0,
  from /usr/include/cygwin/types.h:21,
  from /usr/include/sys/types.h:473,
  from /usr/include/sys/unistd.h:9,
  from /usr/include/unistd.h:4,
  from git-compat-util.h:98,
  from cache.h:4,
  from credential-store.c:1:
 /usr/include/byteswap.h:31:1: note: previous definition of \
 ‘bswap_64’ was here
 Makefile:1985: recipe for target 'credential-store.o' failed
 make: *** [credential-store.o] Error 1

 Note that cygwin has a defintion of 'bswap_64' in the byteswap.h
 header file (which had already been included by git-compat-util.h).
 In order to suppress the error, ensure that the byteswap.h header
 is included, just like the __GNUC__/__GLIBC__ case, rather than
 attempting to define a fallback implementation.

 Signed-off-by: Ramsay Jones ram...@ramsay1.demon.co.uk
 ---
  compat/bswap.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/compat/bswap.h b/compat/bswap.h
 index ea1a9ed..b864abd 100644
 --- a/compat/bswap.h
 +++ b/compat/bswap.h
 @@ -61,7 +61,7 @@ static inline uint32_t git_bswap32(uint32_t x)
  # define ntohll(n) (n)
  # define htonll(n) (n)
  #elif __BYTE_ORDER == __LITTLE_ENDIAN
 -#  if defined(__GNUC__)  defined(__GLIBC__)
 +#  if defined(__GNUC__)  (defined(__GLIBC__) || defined(__CYGWIN__))
  #  include byteswap.h
  #  else /* GNUC  GLIBC */
  static inline uint64_t bswap_64(uint64_t val)


 Nice, much better.

 And here comes a patch for a big endian machine.
 I tryied to copy-paste a patch in my mail program,
 not sure if this applies.

 -- 8 --
 Subject: [PATCH] compat/bswap.h: htonll and ntohll for big endian

 Since commit 452e0f20 (compat: add endianness helpers, 24-10-2013)
 the build on a Linux/ppc gave a warning like this:
 CC ewah/ewah_io.o
 ewah/ewah_io.c: In function ‘ewah_serialize_to’:
 ewah/ewah_io.c:81: warning: implicit declaration of function ‘htonll’
 ewah/ewah_io.c: In function ‘ewah_read_mmap’:
 ewah/ewah_io.c:132: warning: implicit declaration of function ‘ntohll’

 Fix it by placing the #endif for #ifdef bswap32 at the right place.

 Signed-off-by: Torsten Bögershausen tbo...@web.de
 ---
  compat/bswap.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/compat/bswap.h b/compat/bswap.h
 index ea1a9ed..b4ddab0
 --- a/compat/bswap.h
 +++ b/compat/bswap.h
 @@ -46,6 +46,7 @@ static inline uint32_t git_bswap32(uint32_t x)
  #undef htonl
  #define ntohl(x) bswap32(x)
  #define htonl(x) bswap32(x)
 +#endif
  
  #ifndef __BYTE_ORDER
  #  if defined(BYTE_ORDER)  defined(LITTLE_ENDIAN)  
 defined(BIG_ENDIAN)
 @@ -82,4 +83,3 @@ static inline uint64_t bswap_64(uint64_t val)
  #  error Can't define htonll or ntohll!
  #endif
  
 -#endif

 .

 
 Yep, this was the first thing I did as well! ;-) (*late* last night)
 
 I haven't had time today to look into fixing up the msvc build
 (or a complete re-write), so I look forward to seeing your solution.
 (do you have msvc available? - or do you want me to look at fixing
 it? maybe in a day or two?)
 
 ATB,
 Ramsay Jones
Ramsay,
I don't have msvc, so feel 

[PATCH] Test code for htonll, ntohll

2013-10-31 Thread Torsten Bögershausen

test-endianess.c adds test code for htonl(), ntohll()
and the recently introduced ntohll() and htonll()

The test is called in t0070

Signed-off-by: Torsten Bögershausen tbo...@web.de
---
 .gitignore |1 +
 Makefile   |3 +++
 t/t0070-fundamental.sh |3 +++
 test-endianess.c   |   58 
 4 files changed, 65 insertions(+)
 create mode 100644 test-endianess.c

diff --git a/.gitignore b/.gitignore
index 66199ed..750e7d8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -183,6 +183,7 @@
 /test-date
 /test-delta
 /test-dump-cache-tree
+/test-endianess
 /test-scrap-cache-tree
 /test-genrandom
 /test-index-version
diff --git a/Makefile b/Makefile
index 07b0626..50957c7 100644
--- a/Makefile
+++ b/Makefile
@@ -555,6 +555,7 @@ TEST_PROGRAMS_NEED_X += test-ctype
 TEST_PROGRAMS_NEED_X += test-date
 TEST_PROGRAMS_NEED_X += test-delta
 TEST_PROGRAMS_NEED_X += test-dump-cache-tree
+TEST_PROGRAMS_NEED_X += test-endianess
 TEST_PROGRAMS_NEED_X += test-genrandom
 TEST_PROGRAMS_NEED_X += test-hashmap
 TEST_PROGRAMS_NEED_X += test-index-version
@@ -2275,6 +2276,8 @@ test-date$X: date.o ctype.o
 
 test-delta$X: diff-delta.o patch-delta.o
 
+test-endianess$X: test-endianess.c
+
 test-line-buffer$X: vcs-svn/lib.a
 
 test-parse-options$X: parse-options.o parse-options-cb.o
diff --git a/t/t0070-fundamental.sh b/t/t0070-fundamental.sh
index 5ed69a6..dc687da 100755
--- a/t/t0070-fundamental.sh
+++ b/t/t0070-fundamental.sh
@@ -33,5 +33,8 @@ test_expect_success 'check for a bug in the regex routines' '
# if this test fails, re-build git with NO_REGEX=1
test-regex
 '
+test_expect_success 'test endianess, htonll(), ntohll()' '
+   test-endianess
+'
 
 test_done
diff --git a/test-endianess.c b/test-endianess.c
new file mode 100644
index 000..5b49175
--- /dev/null
+++ b/test-endianess.c
@@ -0,0 +1,58 @@
+#include cache.h
+
+int main(int argc, char **argv)
+{
+   union {
+   uint8_t  bytes[8];
+   uint32_t word32;
+   uint64_t word64;
+   } wordll;
+   volatile uint64_t word64;
+   volatile uint32_t word32;
+
+   wordll.bytes[0] = 0x80;
+   wordll.bytes[1] = 0x81;
+   wordll.bytes[2] = 0x82;
+   wordll.bytes[3] = 0x83;
+   wordll.bytes[4] = 0x00;
+   wordll.bytes[5] = 0x01;
+   wordll.bytes[6] = 0x02;
+   wordll.bytes[7] = 0x03;
+
+   word32 = htonl(wordll.word32);
+   if (word32 != 0x80818283)
+   die(htonl word32 != 0x80818283);
+
+   word64 = htonll(wordll.word64);
+   if (word64 != 0x8081828300010203ULL)
+   die(htonll word64 != 0x8081828300010203);
+
+   word32 = ntohl(wordll.word32);
+   if (word32 != 0x80818283)
+   die(ntohl word32 != 0x80818283);
+
+   word64 = ntohll(wordll.word64);
+   if (word64 != 0x8081828300010203ULL)
+   die(ntohll word64 != 0x8081828300010203);
+
+   wordll.bytes[0] = 0x04;
+   wordll.bytes[4] = 0x84;
+
+   word32 = htonl(wordll.word32);
+   if (word32 != 0x04818283)
+   die(htonl word32 != 0x04818283);
+
+   word64 = htonll(wordll.word64);
+   if (word64 != 0x0481828384010203ULL)
+   die(htonll word64 != 0x0481828384010203);
+
+   word32 = ntohl(wordll.word32);
+   if (word32 != 0x04818283)
+   die(ntohl word32 != 0x04818283);
+
+   word64 = ntohll(wordll.word64);
+   if (word64 != 0x0481828384010203ULL)
+   die(ntohll word64 != 0x0481828384010203);
+
+   return 0;
+}
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] gitk: Add First parent checkbox

2013-10-31 Thread Stefan Haller
Sometimes it's desirable to see what changes were introduced by a
merge commit, rather than how conflicts were resolved. This adds
a checkbox which, when turned on, makes gitk show the equivalent
of git show --first-parent commit for merge commits.

Signed-off-by: Stefan Haller ste...@haller-berlin.de
---
This is the same patch as the one I sent in
http://comments.gmane.org/gmane.comp.version-control.git/160920, with
the same issues discussed in that thread. I just brought it up to date
with current master.

 gitk | 25 ++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/gitk b/gitk
index 5cd00d8..3466054 100755
--- a/gitk
+++ b/gitk
@@ -2336,6 +2336,10 @@ proc makewindow {} {
pack .bleft.mid.worddiff -side left -padx 5
 }

+${NS}::checkbutton .bleft.mid.firstparent -text [mc First parent] \
+   -command changefirstparent -variable firstparent
+pack .bleft.mid.firstparent -side left -padx 5
+
 set ctext .bleft.bottom.ctext
 text $ctext -background $bgcolor -foreground $fgcolor \
-state disabled -font textfont \
@@ -7080,6 +7084,7 @@ proc selectline {l isnew {desired_loc {}}} {
 global cmitmode showneartags allcommits
 global targetrow targetid lastscrollrows
 global autoselect autosellen jump_to_here
+global firstparent

 catch {unset pending_select}
 $canv delete hover
@@ -7221,7 +7226,7 @@ proc selectline {l isnew {desired_loc {}}} {
 init_flist [mc Comments]
 if {$cmitmode eq tree} {
gettree $id
-} elseif {[llength $olds] = 1} {
+} elseif {[llength $olds] = 1 || $firstparent} {
startdiff $id
 } else {
mergediff $id
@@ -7624,7 +7629,7 @@ proc diffcmd {ids flags} {
 proc gettreediffs {ids} {
 global treediff treepending limitdiffs vfilelimit curview

-set cmd [diffcmd $ids {--no-commit-id}]
+set cmd [diffcmd $ids {--no-commit-id -m --first-parent}]
 if {$limitdiffs  $vfilelimit($curview) ne {}} {
set cmd [concat $cmd -- $vfilelimit($curview)]
 }
@@ -7710,12 +7715,20 @@ proc changeworddiff {name ix op} {
 reselectline
 }

+proc changefirstparent {} {
+global treediffs
+catch {unset treediffs}
+
+reselectline
+}
+
 proc getblobdiffs {ids} {
 global blobdifffd diffids env
 global diffinhdr treediffs
 global diffcontext
 global ignorespace
 global worddiff
+global firstparent
 global limitdiffs vfilelimit curview
 global diffencoding targetline diffnparents
 global git_version currdiffsubmod
@@ -7728,13 +7741,18 @@ proc getblobdiffs {ids} {
 if {[package vcompare $git_version 1.6.6] = 0} {
set submodule --submodule
 }
-set cmd [diffcmd $ids -p $textconv $submodule  -C --cc --no-commit-id 
-U$diffcontext]
+set cmd [diffcmd $ids -p $textconv $submodule  -C --no-commit-id 
-U$diffcontext]
 if {$ignorespace} {
append cmd  -w
 }
 if {$worddiff ne [mc Line diff]} {
append cmd  --word-diff=porcelain
 }
+if {$firstparent} {
+   append cmd  -m --first-parent
+} else {
+   append cmd  --cc
+}
 if {$limitdiffs  $vfilelimit($curview) ne {}} {
set cmd [concat $cmd -- $vfilelimit($curview)]
 }
@@ -11865,6 +11883,7 @@ set diffcontext 3
 set mergecolors {red blue green purple brown #009090 magenta #808000 
#009000 #ff0080 cyan #b07070 #70b0f0 #70f0b0 #f0b070 #ff70b0}
 set ignorespace 0
 set worddiff 
+set firstparent 0
 set markbgcolor #e0e0ff

 set headbgcolor green
--
1.8.3.2.747.g15edaa9

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Help creating git alias

2013-10-31 Thread Eugene Sajine
On Wed, Oct 30, 2013 at 11:54 PM, Junio C Hamano gits...@pobox.com wrote:
 Eugene Sajine eugu...@gmail.com writes:

 That was my initial intention, because I would like to be able to pass
 parameters like to git log or git blame correctly without the explicit
 use of $1. Could you please advise about how to make it work with the
 !sh -c ?

 Because the same exact (sed 's/@\\S*//') syntax didn't work with sh -c.

 You can make it work if you think step-by-step.  First, this is what
 you want to run:

 sh -c 'git log --format=... $@ | sed s/@\S*//' -

 so that git euguess master..next would turn into

 sh -c 'git log --format=... $@ | sed s/@\S*//' - master..next

 Now, you want to wrap it into an alias, i.e.

 [alias]
 euguess = !sh -c ...

 That ... part is read by our configuration reader, so you need to
 quote the double quotes and backslashes with backslash, which would
 give you something like:

 [alias]
 euguess = !sh -c 'git log --format=\%h %ae %s\ 
 --date=short \$@\ | sed \s/@\\S*//\' -



Junio,

Thanks for taking the time - I appreciate that a lot.
It does work properly now except there is some difference between the
required pathnames:

when i'm in a subfolder in git repo i can say

git log filename

But it seems that if the alias is used i need to specify full path
from the root of the repo no matter where i am.

git log a/b/c/filename

the difference is obviously in the working directory

when i add an alias:

pd = !sh -c 'pwd'

i get this:

$ git pd
/home/users/euguess/repo

$ pwd
/home/users/euguess/repo/a/b/c

Is there any way to help that situation?

Thanks,
Eugene

Thanks,
Eugene
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Fix '\%o' for printf from coreutils

2013-10-31 Thread Jeff King
On Thu, Oct 31, 2013 at 12:51:32PM +0100, Kacper Kornet wrote:

 The printf utility provided by coreutils when interpreting '\%o' format
 does not recognize %o as formatting directive. For example
 printf '\%o 0 returns \%o and warning: ignoring excess arguments,
 starting with ‘0’, which results in failed tests in
 t5309-pack-delta-cycles.sh. In most shells the test ends with success as
 the printf is a builtin utility.
 
 Fix it by using '\\%o' which is interpreted consistently in all versions
 of printf.

Thanks, this makes sense. POSIX says:

 [description of \n, \r, etc...]
 The interpretation of a backslash followed by any other
 sequence of characters is unspecified.

so we were wrong to rely on an unknown backslash-escape
being left alone. A quick grep seems indicate that this is
the only spot with the problem.

-Peff
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[BUG?] error: cache entry has null sha1

2013-10-31 Thread Junio C Hamano
This is totally unrelated to this thread, but I am seeing a strange
error from the let's make sure we won't write null sha1 code we
added recently.  This reproduces reliably for me, even in a freshly
cloned repository without previous rerere records:

 - Check out v1.8.4.1

   $ git checkout v1.8.4.1^0

   at this point your HEAD should be detached.

 - Apply the first patch from this series

   $ git am -3 20131031063530.ga5...@sigill.intra.peff.net

 - Apply the second patch from this series

   $ git am -3 20131031063626.gb5...@sigill.intra.peff.net

   Up to this point things should advance smoothly

 - Attempt to apply the second patch _again_.

   $ git am -3 20131031063626.gb5...@sigill.intra.peff.net

   This should detect a no-op, but somehow leaves things in a
   conflicted state.  I haven't looked into what is wrong, but this
   message is not about this failure.

 - Try to discard

   $ git am --abort
   error: cache entry has null sha1: remote-curl.c
   fatal: unable to write new index file

   This should not happen, no?

git reset --hard will remove the funnies, but still...
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [BUG?] error: cache entry has null sha1

2013-10-31 Thread Jeff King
On Thu, Oct 31, 2013 at 10:11:49AM -0700, Junio C Hamano wrote:

  - Try to discard
 
$ git am --abort
error: cache entry has null sha1: remote-curl.c
fatal: unable to write new index file
 
This should not happen, no?
 
 git reset --hard will remove the funnies, but still...

I ran into this recently, too. Isn't it just the twoway_merge bug we
were discussing here:

  http://thread.gmane.org/gmane.comp.version-control.git/202440/focus=212316

I don't think we ever actually applied a fix.

-Peff
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] commit: Add -f, --fixes commit option to add Fixes: line

2013-10-31 Thread Junio C Hamano
Duy Nguyen pclo...@gmail.com writes:

 OK how about, if $GIT_DIR/hooks/something is a directory, then the
 directory must contain a file named index, listing all the hooks of
 type something. All the hooks in index will be executed in the
 listing order.

Hooks that take arbitrary amount of information from the body read
their standard input. How are your multiple hooks supposed to
interact?

Hooks that prevent you from doing something stupid signal allow/deny
with their exit code. Do you fail a commit if any of your pre-commit
hook fails, or is it OK to commit as long as one of them says so?
If the former, do all the hooks described in the index still run, or
does the first failure short-cut the remainder?
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [BUG?] error: cache entry has null sha1

2013-10-31 Thread Jeff King
On Thu, Oct 31, 2013 at 01:15:39PM -0400, Jeff King wrote:

 On Thu, Oct 31, 2013 at 10:11:49AM -0700, Junio C Hamano wrote:
 
   - Try to discard
  
 $ git am --abort
 error: cache entry has null sha1: remote-curl.c
 fatal: unable to write new index file
  
 This should not happen, no?
  
  git reset --hard will remove the funnies, but still...
 
 I ran into this recently, too. Isn't it just the twoway_merge bug we
 were discussing here:
 
   http://thread.gmane.org/gmane.comp.version-control.git/202440/focus=212316
 
 I don't think we ever actually applied a fix.

Also, the followup:

  http://thread.gmane.org/gmane.comp.version-control.git/217172

-Peff
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Help creating git alias

2013-10-31 Thread David Aguilar
On Thu, Oct 31, 2013 at 11:36:59AM -0400, Eugene Sajine wrote:
 On Wed, Oct 30, 2013 at 11:54 PM, Junio C Hamano gits...@pobox.com wrote:
  Eugene Sajine eugu...@gmail.com writes:
 
  That was my initial intention, because I would like to be able to pass
  parameters like to git log or git blame correctly without the explicit
  use of $1. Could you please advise about how to make it work with the
  !sh -c ?
 
  Because the same exact (sed 's/@\\S*//') syntax didn't work with sh -c.
 
  You can make it work if you think step-by-step.  First, this is what
  you want to run:
 
  sh -c 'git log --format=... $@ | sed s/@\S*//' -
 
  so that git euguess master..next would turn into
 
  sh -c 'git log --format=... $@ | sed s/@\S*//' - master..next
 
  Now, you want to wrap it into an alias, i.e.
 
  [alias]
  euguess = !sh -c ...
 
  That ... part is read by our configuration reader, so you need to
  quote the double quotes and backslashes with backslash, which would
  give you something like:
 
  [alias]
  euguess = !sh -c 'git log --format=\%h %ae %s\ 
  --date=short \$@\ | sed \s/@\\S*//\' -
 
 
 
 Junio,
 
 Thanks for taking the time - I appreciate that a lot.
 It does work properly now except there is some difference between the
 required pathnames:
 
 when i'm in a subfolder in git repo i can say
 
 git log filename
 
 But it seems that if the alias is used i need to specify full path
 from the root of the repo no matter where i am.
 
 git log a/b/c/filename
 
 the difference is obviously in the working directory
 
 when i add an alias:
 
 pd = !sh -c 'pwd'
 
 i get this:
 
 $ git pd
 /home/users/euguess/repo
 
 $ pwd
 /home/users/euguess/repo/a/b/c
 
 Is there any way to help that situation?

Here's the relevant details from Documentation/config.txt:


If the alias expansion is prefixed with an exclamation point,
it will be treated as a shell command.  For example, defining
alias.new = !gitk --all --not ORIG_HEAD, the invocation
git new is equivalent to running the shell command
gitk --all --not ORIG_HEAD.  Note that shell commands will be
executed from the top-level directory of a repository, which may
not necessarily be the current directory.

'GIT_PREFIX' is set as returned by running 'git rev-parse --show-prefix'
from the original current directory. See linkgit:git-rev-parse[1].


The $GIT_PREFIX variable should be available to the alias; it is
a path relative to the root which corresponds to the current
directory.

That doesn't quite play well with these aliases because they use
$@, though.

One way to do it is to add another layer of indirection.  Maybe
someone else on this list has a better suggestion, but this
should do the trick...

Create a shell script to contain your alias, and then point
your alias at it.  e.g.

[alias]
example = !/path/to/alias-script \$@\

and then the script can look like:

#!/bin/sh

unset CDPATH
if test -n $GIT_PREFIX
then
cd $GIT_PREFIX
fi
git log --format='%h %ae %s' --date=short $@ | sed 's/@\\S*//'


...or something like that.  I hope that helps.
I'm also curious if there's a way to avoid needing the extra script...

...

A-ha.. I think adding the chdir to alias is possible using a function.

[alias]
example = !f() { cd \${GIT_PREFIX:-.}\  git log \$@\; }; f

Does that work for you?
I hope that helps.

cheers,
-- 
David
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 00/10] transport-helper: updates

2013-10-31 Thread Max Horn

On 31.10.2013, at 10:36, Felipe Contreras felipe.contre...@gmail.com wrote:

 Hi,
 
 Here are the patches that allow transport helpers to be completely 
 transparent;
 renaming branches, deleting them, custom refspecs, --force, --dry-run,
 reporting forced update, everything works.

I looked through this patch series in detail, and it looks fine to me. Indeed, 
it fixes several nuisances when using remote-helpers, and as such would be a 
definite win. In other words: Would be really nice to see these applied!


Cheers,
Max



signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: [PATCH 00/16] Trivial patches

2013-10-31 Thread Max Horn

On 31.10.2013, at 10:25, Felipe Contreras felipe.contre...@gmail.com wrote:

 Most of these have been sent before, but were not applied for one reason or
 another.

All of these look fine and sensible to me. Some of the latter patches in the 
series might be a bit subjective (e.g. I personally don't mind yoda 
conditions at all), but none do harm, and most are a clear improvement. So I am 
all for applying this.

Cheers,
Max

 
 Felipe Contreras (16):
  merge: simplify ff-only option
  t: replace pulls with merges
  pull: cleanup documentation
  fetch: add missing documentation
  revision: add missing include
  shortlog: add missing declaration
  branch: trivial style fix
  sha1-name: trivial style cleanup
  transport-helper: trivial style fix
  describe: trivial style fixes
  pretty: trivial style fix
  revision: trivial style fixes
  diff: trivial style fix
  run-command: trivial style fixes
  setup: trivial style fixes
  add: avoid yoda conditions
 
 Documentation/git-fetch.txt|  3 +++
 Documentation/git-pull.txt |  4 ++--
 builtin/add.c  |  2 +-
 builtin/branch.c   |  3 +--
 builtin/describe.c |  7 +++
 builtin/diff.c |  2 +-
 builtin/merge.c| 11 ++-
 pretty.c   |  2 +-
 revision.c | 14 ++
 revision.h |  1 +
 run-command.c  | 13 +
 setup.c|  4 ++--
 sha1_name.c|  1 -
 shortlog.h |  2 ++
 t/annotate-tests.sh|  2 +-
 t/t4200-rerere.sh  |  2 +-
 t/t9114-git-svn-dcommit-merge.sh   |  2 +-
 t/t9500-gitweb-standalone-no-errors.sh |  2 +-
 transport-helper.c |  1 +
 19 files changed, 35 insertions(+), 43 deletions(-)
 
 -- 
 1.8.4.2+fc1
 
 --
 To unsubscribe from this list: send the line unsubscribe git in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 



signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: [PATCH 01/16] merge: simplify ff-only option

2013-10-31 Thread Junio C Hamano
Felipe Contreras felipe.contre...@gmail.com writes:

 No functional changes.

 Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
 ---
  builtin/merge.c | 11 ++-
  1 file changed, 2 insertions(+), 9 deletions(-)

 diff --git a/builtin/merge.c b/builtin/merge.c
 index 02a69c1..41fb66d 100644
 --- a/builtin/merge.c
 +++ b/builtin/merge.c
 @@ -186,13 +186,6 @@ static int option_parse_n(const struct option *opt,
   return 0;
  }
  
 -static int option_parse_ff_only(const struct option *opt,
 -   const char *arg, int unset)
 -{
 - fast_forward = FF_ONLY;
 - return 0;
 -}
 -
  static struct option builtin_merge_options[] = {
   { OPTION_CALLBACK, 'n', NULL, NULL, NULL,
   N_(do not show a diffstat at the end of the merge),
 @@ -210,9 +203,9 @@ static struct option builtin_merge_options[] = {
   OPT_BOOL('e', edit, option_edit,
   N_(edit message before committing)),
   OPT_SET_INT(0, ff, fast_forward, N_(allow fast-forward (default)), 
 FF_ALLOW),
 - { OPTION_CALLBACK, 0, ff-only, NULL, NULL,
 + { OPTION_SET_INT, 0, ff-only, fast_forward, NULL,
   N_(abort if fast-forward is not possible),
 - PARSE_OPT_NOARG | PARSE_OPT_NONEG, option_parse_ff_only },
 + PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, FF_ONLY },
   OPT_RERERE_AUTOUPDATE(allow_rerere_auto),
   OPT_BOOL(0, verify-signatures, verify_signatures,
   N_(Verify that the named commit has a valid GPG signature)),

Looks good; thanks.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Help creating git alias

2013-10-31 Thread Junio C Hamano
David Aguilar dav...@gmail.com writes:

 A-ha.. I think adding the chdir to alias is possible using a function.

You do not have to use a function to do so, no?
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [BUG?] error: cache entry has null sha1

2013-10-31 Thread Junio C Hamano
Thanks for the pointers.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 00/10] transport-helper: updates

2013-10-31 Thread Junio C Hamano
Max Horn m...@quendi.de writes:

 On 31.10.2013, at 10:36, Felipe Contreras felipe.contre...@gmail.com
 wrote:

 Hi,
 
 Here are the patches that allow transport helpers to be completely
 transparent;
 renaming branches, deleting them, custom refspecs, --force,
 --dry-run,
 reporting forced update, everything works.

 I looked through this patch series in detail, and it looks fine to
 me. Indeed, it fixes several nuisances when using remote-helpers, and
 as such would be a definite win.

Nice.

 In other words: Would be really nice to see these applied!

The series is sitting on the 'pu' branch, and I think there were
some fixup suggestions during the review, so it may need to be
rerolled before advancing to 'next'.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 04/16] fetch: add missing documentation

2013-10-31 Thread Junio C Hamano
Felipe Contreras felipe.contre...@gmail.com writes:

 There's no mention of the 'origin' default, or the fact that the
 upstream tracking branch remote is used.

 Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
 ---
  Documentation/git-fetch.txt | 3 +++
  1 file changed, 3 insertions(+)

 diff --git a/Documentation/git-fetch.txt b/Documentation/git-fetch.txt
 index e08a028..7e75dc4 100644
 --- a/Documentation/git-fetch.txt
 +++ b/Documentation/git-fetch.txt
 @@ -37,6 +37,9 @@ or from several repositories at once if group is given and
  there is a remotes.group entry in the configuration file.
  (See linkgit:git-config[1]).
  
 +When no remote is specified, by the default the `origin` remote will be used,

I recall there were typofix comments on this line.

 +unless there's an upstream branch configured for the current branch.

Also there was a phrasing comment on this one, I think.

Resending without rerolling is not very much appreciated.


 +
  OPTIONS
  ---
  include::fetch-options.txt[]
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 05/16] revision: add missing include

2013-10-31 Thread Junio C Hamano
Felipe Contreras felipe.contre...@gmail.com writes:

 Otherwise we might not have 'struct diff_options'.

 Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
 ---
  revision.h | 1 +
  1 file changed, 1 insertion(+)

 diff --git a/revision.h b/revision.h
 index e7f1d21..89132df 100644
 --- a/revision.h
 +++ b/revision.h
 @@ -5,6 +5,7 @@
  #include grep.h
  #include notes.h
  #include commit.h
 +#include diff.h
  
  #define SEEN (1u0)
  #define UNINTERESTING   (1u1)

This is a step in the right direction to change the contract between
this header file and its consumers, but I think it falls short of
doing a good job at it.

The rule used to be that if you use a declaration in revision.h,
you must include diff.h before including it, even if you do not use
any declaration made in diff.h yourself. 

The new rule this patch introduces is if you use a declaration in
foo.h, include foo.h, period---foo.h should handle its requirement
on its own internally and consumers should not have to care, which
is much saner.

But the patch needs to also remove '#include diff.h' from existing
consumers that themselves do not use any declaration from diff.h
(e.g. bundle.c; there are others), while keeping the inclusion in
those that do (e.g. builtin/commit.c). That can be a separate patch
that immediately follow this one, or a part of the same patch.

Thanks.

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 03/16] pull: cleanup documentation

2013-10-31 Thread Junio C Hamano
Felipe Contreras felipe.contre...@gmail.com writes:

 'origin/master' is very clear, no need to specify the 'remotes/' prefix,
 or babysit the user.

 Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
 ---
  Documentation/git-pull.txt | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

 diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt
 index beea10b..03a39bc 100644
 --- a/Documentation/git-pull.txt
 +++ b/Documentation/git-pull.txt
 @@ -39,7 +39,7 @@ Assume the following history exists and the current branch 
 is
  `master`:
  
  
 -   A---B---C master on origin
 +   A---B---C origin/master
/
  D---E---F---G master
  

This change is wrong; the illustration depicts the distributed world
(i.e. a fetch has not happened yet).  The next sentence after this
picture reads:

Then `git pull` will fetch and replay the changes from the remote
`master` branch since it diverged from the local `master` 

In other words, your (remotes/)origin/master has _not_ caught up to
the reality.

 @@ -51,7 +51,7 @@ result in a new commit along with the names of the two 
 parent commits
  and a log message from the user describing the changes.
  
  
 -   A---B---C remotes/origin/master
 +   A---B---C origin/master
/ \
  D---E---F---G---H master
  

This is a good change, especially in today's world.

Thanks.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Help creating git alias

2013-10-31 Thread David Aguilar
On Thu, Oct 31, 2013 at 11:07:19AM -0700, Junio C Hamano wrote:
 David Aguilar dav...@gmail.com writes:
 
  A-ha.. I think adding the chdir to alias is possible using a function.
 
 You do not have to use a function to do so, no?

Right, of course.

So something like:

[alias]
example = !cd ${GIT_PREFIX:-.}  git log \$@\

should do the trick.
-- 
David
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 01/10] transport-helper: fix extra lines

2013-10-31 Thread Junio C Hamano
Felipe Contreras felipe.contre...@gmail.com writes:

 Commit 9c51558 (transport-helper: trivial code shuffle) moved these
 lines above, but 99d9ec0 (Merge branch 'fc/transport-helper-no-refspec')
 had a wrong merge conflict and readded them.

 Reported-by: Richard Hansen rhan...@bbn.com
 Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
 ---

Ahh, sorry about that.  Will apply with a retitle.

  transport-helper.c | 3 ---
  1 file changed, 3 deletions(-)

 diff --git a/transport-helper.c b/transport-helper.c
 index b32e2d6..985eeea 100644
 --- a/transport-helper.c
 +++ b/transport-helper.c
 @@ -874,9 +874,6 @@ static int push_refs_with_export(struct transport 
 *transport,
   }
   free(private);
  
 - if (ref-deletion)
 - die(remote-helpers do not support ref deletion);
 -
   if (ref-peer_ref) {
   if (strcmp(ref-peer_ref-name, ref-name))
   die(remote-helpers do not support old:new 
 syntax);
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 03/10] transport-helper: add 'force' to 'export' helpers

2013-10-31 Thread Junio C Hamano
Felipe Contreras felipe.contre...@gmail.com writes:

 Otherwise they cannot know when to force the push or not (other than
 hacks).
 ...
 diff --git a/transport-helper.c b/transport-helper.c
 index d05fc7c..ed238e5 100644
 --- a/transport-helper.c
 +++ b/transport-helper.c
 @@ -854,6 +854,11 @@ static int push_refs_with_export(struct transport 
 *transport,
   die(helper %s does not support dry-run, data-name);
   }
  
 + if (flags  TRANSPORT_PUSH_FORCE) {
 + if (set_helper_option(transport, force, true) != 0)
 + die(helper %s does not support 'force', data-name);
 + }
 +

Does this cause a git push --force $there A:B to fail when $there
is a destination that goes via an existing helper does not suport
force option?

Should it fail even when the current value of B is an ancestor of A
(i.e. when an unforced push would succeed)?



--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 06/10] fast-export: add new --refspec option

2013-10-31 Thread Junio C Hamano
Felipe Contreras felipe.contre...@gmail.com writes:

 +test_expect_success 'use refspec' '
 + git fast-export --refspec refs/heads/master:refs/heads/foobar master | \
 + grep ^commit  | sort | uniq  actual 

It feels somewhat redundant that you have to twice say that you are
pushing your master, once with --refspec and then the branch
name.  Is this the best we can do?

If the answer is yes, I guess it is OK to leave the external
interface to fast-export of this patch as-is, but if we can do
better, then we'd be better off without redundancy.

There are quite a few shell script style violations in this test, by
the way.  You do not want the trailing  \ after a pipe (the shell,
when seeing a line that ends with |, knows you haven't finished
giving it the pipeline).  Also we do not put extra space between a
redirection operator and the target filename.



 + echo commit refs/heads/foobar  expected 
 + test_cmp expected actual
 +'
 +
  test_done
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 00/10] transport-helper: updates

2013-10-31 Thread Felipe Contreras
On Thu, Oct 31, 2013 at 12:10 PM, Junio C Hamano gits...@pobox.com wrote:
 Max Horn m...@quendi.de writes:

 In other words: Would be really nice to see these applied!

 The series is sitting on the 'pu' branch, and I think there were
 some fixup suggestions during the review, so it may need to be
 rerolled before advancing to 'next'.

The suggestions are applied, as you can see in the diff.

-- 
Felipe Contreras
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] t: branch: improve test rollback

2013-10-31 Thread Junio C Hamano
Felipe Contreras felipe.contre...@gmail.com writes:

 After every test the environment should be as close as to how it was
 before as possible.

Alternatively, each individual tests in a sequence of tests can
choose to set the test environment to its preferred state before
proceeding.  

Starting from a pristine state (i.e. the goal the above aspires to
reach) is probably more desirable, but in practice we could go
either way.  In any case we should consistently stick to one inside
a single test.

 Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
 ---
  t/t3200-branch.sh | 71 
 +++
  1 file changed, 35 insertions(+), 36 deletions(-)

 diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
 index 0fe7647..33673e0 100755
 --- a/t/t3200-branch.sh
 +++ b/t/t3200-branch.sh
 @@ -329,7 +329,7 @@ test_expect_success 'tracking setup fails on non-matching 
 refspec' '
  '
  
  test_expect_success 'test tracking setup via config' '
 - git config branch.autosetupmerge true 
 + test_config branch.autosetupmerge true 
   git config remote.local.url . 
   git config remote.local.fetch refs/heads/*:refs/remotes/local/* 

And remote.local.* setting does not follow that pristine
principle, making the result of applying this patch inconsistent.
Is that desirable?



   (git show-ref -q refs/remotes/local/master || git fetch local) 
 @@ -339,20 +339,18 @@ test_expect_success 'test tracking setup via config' '
  '
  
  test_expect_success 'test overriding tracking setup via --no-track' '
 - git config branch.autosetupmerge true 
 + test_config branch.autosetupmerge true 
   git config remote.local.url . 
   git config remote.local.fetch refs/heads/*:refs/remotes/local/* 
   (git show-ref -q refs/remotes/local/master || git fetch local) 
   git branch --no-track my2 local/master 
 - git config branch.autosetupmerge false 
   ! test $(git config branch.my2.remote) = local 
   ! test $(git config branch.my2.merge) = refs/heads/master
  '
  
  test_expect_success 'no tracking without .fetch entries' '
 - git config branch.autosetupmerge true 
 + test_config branch.autosetupmerge true 
   git branch my6 s 
 - git config branch.autosetupmerge false 
   test -z $(git config branch.my6.remote) 
   test -z $(git config branch.my6.merge)
  '
 @@ -387,9 +385,8 @@ test_expect_success 'test --track without .fetch entries' 
 '
  '
  
  test_expect_success 'branch from non-branch HEAD w/autosetupmerge=always' '
 - git config branch.autosetupmerge always 
 - git branch my9 HEAD^ 
 - git config branch.autosetupmerge false
 + test_config branch.autosetupmerge always 
 + git branch my9 HEAD^
  '
  
  test_expect_success 'branch from non-branch HEAD w/--track causes failure' '
 @@ -406,9 +403,9 @@ test_expect_success '--set-upstream-to fails on multiple 
 branches' '
  '
  
  test_expect_success '--set-upstream-to fails on detached HEAD' '
 + test_when_finished git checkout - 
   git checkout HEAD^{} 
 - test_must_fail git branch --set-upstream-to master 
 - git checkout -
 + test_must_fail git branch --set-upstream-to master
  '
  
  test_expect_success '--set-upstream-to fails on a missing dst branch' '
 @@ -460,9 +457,9 @@ test_expect_success '--unset-upstream should fail on 
 multiple branches' '
  '
  
  test_expect_success '--unset-upstream should fail on detached HEAD' '
 + test_when_finished git checkout - 
   git checkout HEAD^{} 
 - test_must_fail git branch --unset-upstream 
 - git checkout -
 + test_must_fail git branch --unset-upstream
  '
  
  test_expect_success 'test --unset-upstream on a particular branch' '
 @@ -541,7 +538,8 @@ test_expect_success 'checkout -b with -l makes reflog 
 when core.logAllRefUpdates
  '
  
  test_expect_success 'avoid ambiguous track' '
 - git config branch.autosetupmerge true 
 + test_when_finished git remote rm ambi1  git remote rm ambi2 
 + test_config branch.autosetupmerge true 
   git config remote.ambi1.url lalala 
   git config remote.ambi1.fetch refs/heads/lalala:refs/heads/master 
   git config remote.ambi2.url lilili 
 @@ -553,7 +551,7 @@ test_expect_success 'avoid ambiguous track' '
  test_expect_success 'autosetuprebase local on a tracked local branch' '
   git config remote.local.url . 
   git config remote.local.fetch refs/heads/*:refs/remotes/local/* 
 - git config branch.autosetuprebase local 
 + test_config branch.autosetuprebase local 
   (git show-ref -q refs/remotes/local/o || git fetch local) 
   git branch mybase 
   git branch --track myr1 mybase 
 @@ -565,7 +563,7 @@ test_expect_success 'autosetuprebase local on a tracked 
 local branch' '
  test_expect_success 'autosetuprebase always on a tracked local branch' '
   git config remote.local.url . 
   git config remote.local.fetch refs/heads/*:refs/remotes/local/* 
 - git 

Re: [PATCH v5 00/10] transport-helper: updates

2013-10-31 Thread Junio C Hamano
Junio C Hamano gits...@pobox.com writes:

 Max Horn m...@quendi.de writes:

 On 31.10.2013, at 10:36, Felipe Contreras felipe.contre...@gmail.com
 wrote:

 Hi,
 
 Here are the patches that allow transport helpers to be completely
 transparent;
 renaming branches, deleting them, custom refspecs, --force,
 --dry-run,
 reporting forced update, everything works.

 I looked through this patch series in detail, and it looks fine to
 me. Indeed, it fixes several nuisances when using remote-helpers, and
 as such would be a definite win.

 Nice.

 In other words: Would be really nice to see these applied!

 The series is sitting on the 'pu' branch, and I think there were
 some fixup suggestions during the review, so it may need to be
 rerolled before advancing to 'next'.

Ah, I spoke too early; this is v5, updated from v4.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 03/16] pull: cleanup documentation

2013-10-31 Thread Felipe Contreras
On Thu, Oct 31, 2013 at 12:11 PM, Junio C Hamano gits...@pobox.com wrote:
 Felipe Contreras felipe.contre...@gmail.com writes:

 --- a/Documentation/git-pull.txt
 +++ b/Documentation/git-pull.txt
 @@ -39,7 +39,7 @@ Assume the following history exists and the current branch 
 is
  `master`:

  
 -   A---B---C master on origin
 +   A---B---C origin/master
/
  D---E---F---G master
  

 This change is wrong; the illustration depicts the distributed world
 (i.e. a fetch has not happened yet).

That is an irrelevant implementation detail, specially at this high
level. In the user's mind origin/master means master on origin.

If you want to be pedantic, this is the reality:

  
  D---E---F---G master
  

-- 
Felipe Contreras
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] t: branch: improve test rollback

2013-10-31 Thread Felipe Contreras
On Thu, Oct 31, 2013 at 12:32 PM, Junio C Hamano gits...@pobox.com wrote:
 Felipe Contreras felipe.contre...@gmail.com writes:

 diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
 index 0fe7647..33673e0 100755
 --- a/t/t3200-branch.sh
 +++ b/t/t3200-branch.sh
 @@ -329,7 +329,7 @@ test_expect_success 'tracking setup fails on 
 non-matching refspec' '
  '

  test_expect_success 'test tracking setup via config' '
 - git config branch.autosetupmerge true 
 + test_config branch.autosetupmerge true 
   git config remote.local.url . 
   git config remote.local.fetch refs/heads/*:refs/remotes/local/* 

 And remote.local.* setting does not follow that pristine
 principle, making the result of applying this patch inconsistent.
 Is that desirable?

This patch is *improving* test rollback, it's not making it perfect.

Let not the perfect be the enemy of the good.

-- 
Felipe Contreras
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] t: branch: improve test rollback

2013-10-31 Thread Junio C Hamano
Felipe Contreras felipe.contre...@gmail.com writes:

 On Thu, Oct 31, 2013 at 12:32 PM, Junio C Hamano gits...@pobox.com wrote:
 Felipe Contreras felipe.contre...@gmail.com writes:

 diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
 index 0fe7647..33673e0 100755
 --- a/t/t3200-branch.sh
 +++ b/t/t3200-branch.sh
 @@ -329,7 +329,7 @@ test_expect_success 'tracking setup fails on 
 non-matching refspec' '
  '

  test_expect_success 'test tracking setup via config' '
 - git config branch.autosetupmerge true 
 + test_config branch.autosetupmerge true 
   git config remote.local.url . 
   git config remote.local.fetch refs/heads/*:refs/remotes/local/* 

 And remote.local.* setting does not follow that pristine
 principle, making the result of applying this patch inconsistent.
 Is that desirable?

 This patch is *improving* test rollback, it's not making it perfect.

 Let not the perfect be the enemy of the good.

The patch is making it worse by stopping in the middle.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 06/10] fast-export: add new --refspec option

2013-10-31 Thread Felipe Contreras
On Thu, Oct 31, 2013 at 12:26 PM, Junio C Hamano gits...@pobox.com wrote:
 Felipe Contreras felipe.contre...@gmail.com writes:

 +test_expect_success 'use refspec' '
 + git fast-export --refspec refs/heads/master:refs/heads/foobar master | 
 \
 + grep ^commit  | sort | uniq  actual 

 It feels somewhat redundant that you have to twice say that you are
 pushing your master, once with --refspec and then the branch
 name.  Is this the best we can do?

As this has been discussed before and no other solution came forward, yes.

-- 
Felipe Contreras
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 08/10] fast-import: add support to delete refs

2013-10-31 Thread Max Horn

On 31.10.2013, at 10:36, Felipe Contreras felipe.contre...@gmail.com wrote:

 Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
 ---
 Documentation/git-fast-import.txt |  3 +++
 fast-import.c | 13 ++---
 t/t9300-fast-import.sh| 18 ++
 3 files changed, 31 insertions(+), 3 deletions(-)
 
 diff --git a/Documentation/git-fast-import.txt 
 b/Documentation/git-fast-import.txt
 index 73f9806..c49ede4 100644
 --- a/Documentation/git-fast-import.txt
 +++ b/Documentation/git-fast-import.txt
 @@ -483,6 +483,9 @@ Marks must be declared (via `mark`) before they can be 
 used.
 * Any valid Git SHA-1 expression that resolves to a commit.  See
   ``SPECIFYING REVISIONS'' in linkgit:gitrevisions[7] for details.
 
 +* The special null SHA-1 (40 zeros) specifices that the branch is to be

s/specifices/specifies/

(this was previously pointed out by Eric Sunshine for patch 7 of v4 of this 
series).



signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: [PATCH v5 00/10] transport-helper: updates

2013-10-31 Thread Max Horn

On 31.10.2013, at 19:10, Junio C Hamano gits...@pobox.com wrote:

 Max Horn m...@quendi.de writes:
 
 On 31.10.2013, at 10:36, Felipe Contreras felipe.contre...@gmail.com
 wrote:
 
 Hi,
 
 Here are the patches that allow transport helpers to be completely
 transparent;
 renaming branches, deleting them, custom refspecs, --force,
 --dry-run,
 reporting forced update, everything works.
 
 I looked through this patch series in detail, and it looks fine to
 me. Indeed, it fixes several nuisances when using remote-helpers, and
 as such would be a definite win.
 
 Nice.
 
 In other words: Would be really nice to see these applied!
 
 The series is sitting on the 'pu' branch, and I think there were
 some fixup suggestions during the review, so it may need to be
 rerolled before advancing to 'next'.

You are of course right. Next time I comment, I'll make sure to check whether 
previous review suggestions have been picked up.



signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: [PATCH v5 03/10] transport-helper: add 'force' to 'export' helpers

2013-10-31 Thread Felipe Contreras
On Thu, Oct 31, 2013 at 12:21 PM, Junio C Hamano gits...@pobox.com wrote:
 Felipe Contreras felipe.contre...@gmail.com writes:

 Otherwise they cannot know when to force the push or not (other than
 hacks).
 ...
 diff --git a/transport-helper.c b/transport-helper.c
 index d05fc7c..ed238e5 100644
 --- a/transport-helper.c
 +++ b/transport-helper.c
 @@ -854,6 +854,11 @@ static int push_refs_with_export(struct transport 
 *transport,
   die(helper %s does not support dry-run, data-name);
   }

 + if (flags  TRANSPORT_PUSH_FORCE) {
 + if (set_helper_option(transport, force, true) != 0)
 + die(helper %s does not support 'force', data-name);
 + }
 +

 Does this cause a git push --force $there A:B to fail when $there
 is a destination that goes via an existing helper does not suport
 force option?

Yes.

 Should it fail even when the current value of B is an ancestor of A
 (i.e. when an unforced push would succeed)?

It might make sense to fail only when the push is non-fast-forward,
but it's not so straight-forward to implement.

-- 
Felipe Contreras
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] t: branch: improve test rollback

2013-10-31 Thread Felipe Contreras
On Thu, Oct 31, 2013 at 12:50 PM, Junio C Hamano gits...@pobox.com wrote:
 Felipe Contreras felipe.contre...@gmail.com writes:

 On Thu, Oct 31, 2013 at 12:32 PM, Junio C Hamano gits...@pobox.com wrote:
 Felipe Contreras felipe.contre...@gmail.com writes:

 diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
 index 0fe7647..33673e0 100755
 --- a/t/t3200-branch.sh
 +++ b/t/t3200-branch.sh
 @@ -329,7 +329,7 @@ test_expect_success 'tracking setup fails on 
 non-matching refspec' '
  '

  test_expect_success 'test tracking setup via config' '
 - git config branch.autosetupmerge true 
 + test_config branch.autosetupmerge true 
   git config remote.local.url . 
   git config remote.local.fetch refs/heads/*:refs/remotes/local/* 

 And remote.local.* setting does not follow that pristine
 principle, making the result of applying this patch inconsistent.
 Is that desirable?

 This patch is *improving* test rollback, it's not making it perfect.

 Let not the perfect be the enemy of the good.

 The patch is making it worse by stopping in the middle.

Whatever.

-- 
Felipe Contreras
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 03/16] pull: cleanup documentation

2013-10-31 Thread Junio C Hamano
Felipe Contreras felipe.contre...@gmail.com writes:

 On Thu, Oct 31, 2013 at 12:11 PM, Junio C Hamano gits...@pobox.com wrote:
 Felipe Contreras felipe.contre...@gmail.com writes:

 --- a/Documentation/git-pull.txt
 +++ b/Documentation/git-pull.txt
 @@ -39,7 +39,7 @@ Assume the following history exists and the current 
 branch is
  `master`:

  
 -   A---B---C master on origin
 +   A---B---C origin/master
/
  D---E---F---G master
  

 This change is wrong; the illustration depicts the distributed world
 (i.e. a fetch has not happened yet).

 That is an irrelevant implementation detail, specially at this high
 level. In the user's mind origin/master means master on origin.

You are wrong.  In the user's mind, origin/master means the commit
that used to be at master on origin, and the point of this
illustration is to make them understand that they live in a
distributed world, where their last observation will go stale over
time.


 If you want to be pedantic, this is the reality:

   
   D---E---F---G master
   

You are wrong again.  The reality is more like this:

  origin/master in your repository
  |
  v
  A---B---C master at origin
 /
D---E---F---G master in your repository

if you really want to write origin/master somewhere in this
illustration.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 06/16] shortlog: add missing declaration

2013-10-31 Thread Junio C Hamano
Felipe Contreras felipe.contre...@gmail.com writes:

 Otherwise we would have to include commit.h.

Was there a reason why commit.h is not included here, just like
revision.h would include diff.h, so that users of shortlog.h do not
have to worry about including commit.h themselves?

Note: not requesting the patch to be changed; just inquiring the
reasoning behind a different approach to solve related/same problem.

 Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
 ---
  shortlog.h | 2 ++
  1 file changed, 2 insertions(+)

 diff --git a/shortlog.h b/shortlog.h
 index de4f86f..54bc07c 100644
 --- a/shortlog.h
 +++ b/shortlog.h
 @@ -19,6 +19,8 @@ struct shortlog {
   struct string_list mailmap;
  };
  
 +struct commit;
 +
  void shortlog_init(struct shortlog *log);
  
  void shortlog_add_commit(struct shortlog *log, struct commit *commit);
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 04/16] fetch: add missing documentation

2013-10-31 Thread Felipe Contreras
On Thu, Oct 31, 2013 at 12:10 PM, Junio C Hamano gits...@pobox.com wrote:
 Felipe Contreras felipe.contre...@gmail.com writes:

 diff --git a/Documentation/git-fetch.txt b/Documentation/git-fetch.txt
 index e08a028..7e75dc4 100644
 --- a/Documentation/git-fetch.txt
 +++ b/Documentation/git-fetch.txt
 @@ -37,6 +37,9 @@ or from several repositories at once if group is given 
 and
  there is a remotes.group entry in the configuration file.
  (See linkgit:git-config[1]).

 +When no remote is specified, by the default the `origin` remote will be 
 used,

 I recall there were typofix comments on this line.

--- a/Documentation/git-fetch.txt
+++ b/Documentation/git-fetch.txt
@@ -37,7 +37,7 @@ or from several repositories at once if group is given and
 there is a remotes.group entry in the configuration file.
 (See linkgit:git-config[1]).

-When no remote is specified, by the default the `origin` remote will be used,
+When no remote is specified, by default the `origin` remote will be used,
 unless there's an upstream branch configured for the current branch.

 OPTIONS

 +unless there's an upstream branch configured for the current branch.

 Also there was a phrasing comment on this one, I think.

There was no constructive comment, no alternative was proposed.

The conclusion of the discussion (at least mine) is that the phrasing is fine.

 Resending without rerolling is not very much appreciated.

I missed a valid comment in one of my 160 pending patches. Sue me.

-- 
Felipe Contreras
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 03/10] transport-helper: add 'force' to 'export' helpers

2013-10-31 Thread Junio C Hamano
Felipe Contreras felipe.contre...@gmail.com writes:

 On Thu, Oct 31, 2013 at 12:21 PM, Junio C Hamano gits...@pobox.com wrote:
 Felipe Contreras felipe.contre...@gmail.com writes:

 Otherwise they cannot know when to force the push or not (other than
 hacks).
 ...
 diff --git a/transport-helper.c b/transport-helper.c
 index d05fc7c..ed238e5 100644
 --- a/transport-helper.c
 +++ b/transport-helper.c
 @@ -854,6 +854,11 @@ static int push_refs_with_export(struct transport 
 *transport,
   die(helper %s does not support dry-run, data-name);
   }

 + if (flags  TRANSPORT_PUSH_FORCE) {
 + if (set_helper_option(transport, force, true) != 0)
 + die(helper %s does not support 'force', data-name);
 + }
 +

 Does this cause a git push --force $there A:B to fail when $there
 is a destination that goes via an existing helper does not suport
 force option?

 Yes.

 Should it fail even when the current value of B is an ancestor of A
 (i.e. when an unforced push would succeed)?

 It might make sense to fail only when the push is non-fast-forward,
 but it's not so straight-forward to implement.

OK; let's see if anybody screams by cooking the series in 'next'
(that is, when other issues people may discover in the series are
addressed).

Thanks.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 03/16] pull: cleanup documentation

2013-10-31 Thread Max Horn

On 31.10.2013, at 20:00, Junio C Hamano gits...@pobox.com wrote:

 Felipe Contreras felipe.contre...@gmail.com writes:

[...]

 
 
 If you want to be pedantic, this is the reality:
 
  
  D---E---F---G master
  
 
 You are wrong again.  The reality is more like this:
 
  origin/master in your repository
  |
  v
  A---B---C master at origin
 /
D---E---F---G master in your repository
 
 if you really want to write origin/master somewhere in this
 illustration.

Actually, I kind of like that. After just reading the existing phrasing in 
git-pull.txt, I doubt that a newbie would catch the difference between 
origin/master and master at origin. With this illustration, it's very 
clearly conveyed that there is a difference.



signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: [PATCH v5 09/10] fast-export: add support to delete refs

2013-10-31 Thread Max Horn
Actually, I just noticed one thing that I *do* have a question about:

On 31.10.2013, at 10:36, Felipe Contreras felipe.contre...@gmail.com wrote:

 Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
 ---
 builtin/fast-export.c  | 14 ++
 t/t9350-fast-export.sh | 11 +++
 2 files changed, 25 insertions(+)
 
 diff --git a/builtin/fast-export.c b/builtin/fast-export.c
 index b6f623e..8ed41b4 100644
 --- a/builtin/fast-export.c
 +++ b/builtin/fast-export.c
 @@ -673,6 +673,19 @@ static void import_marks(char *input_file)
   fclose(f);
 }
 
 +static void handle_deletes(void)
 +{
 + int i;
 + for (i = 0; i  refspecs_nr; i++) {
 + struct refspec *refspec = refspecs[i];
 + if (*refspec-src)
 + continue;
 +
 + printf(reset %s\nfrom %s\n\n,
 + refspec-dst, sha1_to_hex(null_sha1));

If I understand it right, this issues a reset command in the fast-import 
stream, resetting a ref to an all-zero SHA1. I had a look at the 
git-fast-import documentation, but I found that it does not explicitly cover 
this case. In particular, the reset command does not specify that an all-zero 
SHA1 should be treated as delete this ref. On the other hand, the docs for 
reset seem to indicate that one can omit the from part, although I couldn't 
tell for sure what that would mean, either.

I have not yet tried to dive into the code to figure out what actually happens, 
but I assume Felipe did that resp. tested it, and so supposedly doing this 
works, at least for git resp. existing transport helpers. But I wonder if other 
implementers of the fast-import format would handle it properly?

In any case, it seems to me that this is a gap in the documentation, isn't it? 
Or am I just being dense?



signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: Help creating git alias

2013-10-31 Thread Eugene Sajine
On Thu, Oct 31, 2013 at 2:15 PM, David Aguilar dav...@gmail.com wrote:
 On Thu, Oct 31, 2013 at 11:07:19AM -0700, Junio C Hamano wrote:
 David Aguilar dav...@gmail.com writes:

  A-ha.. I think adding the chdir to alias is possible using a function.

 You do not have to use a function to do so, no?

 Right, of course.

 So something like:

 [alias]
 example = !cd ${GIT_PREFIX:-.}  git log \$@\

 should do the trick.
 --
 David


Awesome! It does work!
One note: i tried the ${GIT_PREFIX:-.}  and ${GIT_PREFIX} and it seems
to give the same results. What is the expected difference here?

Thank you!
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 06/16] shortlog: add missing declaration

2013-10-31 Thread Felipe Contreras
On Thu, Oct 31, 2013 at 1:05 PM, Junio C Hamano gits...@pobox.com wrote:
 Felipe Contreras felipe.contre...@gmail.com writes:

 Otherwise we would have to include commit.h.

 Was there a reason why commit.h is not included here, just like
 revision.h would include diff.h, so that users of shortlog.h do not
 have to worry about including commit.h themselves?

Because you can't do:

struct diff_options;
struct diff_options diffopt;

The storage size is not known, but you can do:

struct diff_options;
struct diff_options *diffopt;

-- 
Felipe Contreras
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] Use the word 'stuck' instead of 'sticked'

2013-10-31 Thread Junio C Hamano
Nicolas Vigier bo...@mars-attacks.org writes:

 The past participle of 'stick' is 'stuck'.

 Signed-off-by: Nicolas Vigier bo...@mars-attacks.org
 ---

Thanks.

It was good that we caught this before introducing the option; the
documentation update does not hurt the users much, but if we unleash
a misspelled option in a release, it is much harder to correct it
later.

Will queue both patches.

  Documentation/gitcli.txt  | 6 +++---
  Documentation/technical/api-parse-options.txt | 6 +++---
  diff.c| 2 +-
  diff.h| 2 +-
  4 files changed, 8 insertions(+), 8 deletions(-)

 diff --git a/Documentation/gitcli.txt b/Documentation/gitcli.txt
 index 3146413cce0d..c87f0ae88d6c 100644
 --- a/Documentation/gitcli.txt
 +++ b/Documentation/gitcli.txt
 @@ -72,11 +72,11 @@ scripting Git:
   * splitting short options to separate words (prefer `git foo -a -b`
 to `git foo -ab`, the latter may not even work).
  
 - * when a command line option takes an argument, use the 'sticked' form.  In
 + * when a command line option takes an argument, use the 'stuck' form.  In
 other words, write `git foo -oArg` instead of `git foo -o Arg` for short
 options, and `git foo --long-opt=Arg` instead of `git foo --long-opt Arg`
 for long options.  An option that takes optional option-argument must be
 -   written in the 'sticked' form.
 +   written in the 'stuck' form.
  
   * when you give a revision parameter to a command, make sure the parameter 
 is
 not ambiguous with a name of a file in the work tree.  E.g. do not write
 @@ -165,7 +165,7 @@ $ git foo -o Arg
  
  
  However, this is *NOT* allowed for switches with an optional value, where the
 -'sticked' form must be used:
 +'stuck' form must be used:
  
  $ git describe --abbrev HEAD # correct
  $ git describe --abbrev=10 HEAD  # correct
 diff --git a/Documentation/technical/api-parse-options.txt 
 b/Documentation/technical/api-parse-options.txt
 index 0be2b5159f1b..be50cf4de35c 100644
 --- a/Documentation/technical/api-parse-options.txt
 +++ b/Documentation/technical/api-parse-options.txt
 @@ -29,9 +29,9 @@ that allow to change the behavior of a command.
  
  The parse-options API allows:
  
 -* 'sticked' and 'separate form' of options with arguments.
 -  `-oArg` is sticked, `-o Arg` is separate form.
 -  `--option=Arg` is sticked, `--option Arg` is separate form.
 +* 'stuck' and 'separate form' of options with arguments.
 +  `-oArg` is stuck, `-o Arg` is separate form.
 +  `--option=Arg` is stuck, `--option Arg` is separate form.
  
  * Long options may be 'abbreviated', as long as the abbreviation
is unambiguous.
 diff --git a/diff.c b/diff.c
 index e34bf971207f..3950e0191067 100644
 --- a/diff.c
 +++ b/diff.c
 @@ -3394,7 +3394,7 @@ int parse_long_opt(const char *opt, const char **argv,
   if (prefixcmp(arg, opt))
   return 0;
   arg += strlen(opt);
 - if (*arg == '=') { /* sticked form: --option=value */
 + if (*arg == '=') { /* stuck form: --option=value */
   *optarg = arg + 1;
   return 1;
   }
 diff --git a/diff.h b/diff.h
 index e34232501ee8..1c05b3a6bec6 100644
 --- a/diff.h
 +++ b/diff.h
 @@ -244,7 +244,7 @@ extern struct diff_filepair *diff_unmerge(struct 
 diff_options *, const char *pat
  #define DIFF_SETUP_USE_SIZE_CACHE4
  
  /*
 - * Poor man's alternative to parse-option, to allow both sticked form
 + * Poor man's alternative to parse-option, to allow both stuck form
   * (--option=value) and separate form (--option value).
   */
  extern int parse_long_opt(const char *opt, const char **argv,
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Help creating git alias

2013-10-31 Thread Junio C Hamano
Eugene Sajine eugu...@gmail.com writes:

 One note: i tried the ${GIT_PREFIX:-.}  and ${GIT_PREFIX} and it seems
 to give the same results. What is the expected difference here?

GIT_PREFIX may be an empty string when you run from the top-level,
in which case you would end up with cd  ... and end up working
in your $HOME.

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 09/10] fast-export: add support to delete refs

2013-10-31 Thread Felipe Contreras
On Thu, Oct 31, 2013 at 1:29 PM, Max Horn m...@quendi.de wrote:
 Actually, I just noticed one thing that I *do* have a question about:

 On 31.10.2013, at 10:36, Felipe Contreras felipe.contre...@gmail.com wrote:

 Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
 ---
 builtin/fast-export.c  | 14 ++
 t/t9350-fast-export.sh | 11 +++
 2 files changed, 25 insertions(+)

 diff --git a/builtin/fast-export.c b/builtin/fast-export.c
 index b6f623e..8ed41b4 100644
 --- a/builtin/fast-export.c
 +++ b/builtin/fast-export.c
 @@ -673,6 +673,19 @@ static void import_marks(char *input_file)
   fclose(f);
 }

 +static void handle_deletes(void)
 +{
 + int i;
 + for (i = 0; i  refspecs_nr; i++) {
 + struct refspec *refspec = refspecs[i];
 + if (*refspec-src)
 + continue;
 +
 + printf(reset %s\nfrom %s\n\n,
 + refspec-dst, sha1_to_hex(null_sha1));

 If I understand it right, this issues a reset command in the fast-import 
 stream, resetting a ref to an all-zero SHA1. I had a look at the 
 git-fast-import documentation, but I found that it does not explicitly cover 
 this case. In particular, the reset command does not specify that an 
 all-zero SHA1 should be treated as delete this ref.

That's what the previous patch does.

 On the other hand, the docs for reset seem to indicate that one can omit 
 the from part, although I couldn't tell for sure what that would mean, 
 either.

It means something different.

 I have not yet tried to dive into the code to figure out what actually 
 happens, but I assume Felipe did that resp. tested it, and so supposedly 
 doing this works, at least for git resp. existing transport helpers. But I 
 wonder if other implementers of the fast-import format would handle it 
 properly?

Try this:

--- a/t/t9350-fast-export.sh
+++ b/t/t9350-fast-export.sh
@@ -519,7 +519,9 @@ test_expect_success 'delete refspec' '
from 

EOF
-   test_cmp expected actual
+   test_cmp expected actual 
+   git fast-import  actual 
+   test_must_fail git rev-parse -q --verify refs/heads/to-delete
 '

 test_done

-- 
Felipe Contreras
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 03/16] pull: cleanup documentation

2013-10-31 Thread Junio C Hamano
Max Horn m...@quendi.de writes:

 ... The reality is more like this:
 
  origin/master in your repository
  |
  v
  A---B---C master at origin
 /
D---E---F---G master in your repository
 
 if you really want to write origin/master somewhere in this
 illustration.

 Actually, I kind of like that. After just reading the existing
 phrasing in git-pull.txt, I doubt that a newbie would catch the
 difference between origin/master and master at origin. With this
 illustration, it's very clearly conveyed that there is a difference.

Yeah, after re-reading the part of the documentation with the
illustration replaced with the above, I was coming to the same
conclusion.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 09/10] fast-export: add support to delete refs

2013-10-31 Thread Max Horn

On 31.10.2013, at 20:41, Felipe Contreras felipe.contre...@gmail.com wrote:

 On Thu, Oct 31, 2013 at 1:29 PM, Max Horn m...@quendi.de wrote:
 Actually, I just noticed one thing that I *do* have a question about:
 
 On 31.10.2013, at 10:36, Felipe Contreras felipe.contre...@gmail.com wrote:
 
 Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
 ---
 builtin/fast-export.c  | 14 ++
 t/t9350-fast-export.sh | 11 +++
 2 files changed, 25 insertions(+)
 
 diff --git a/builtin/fast-export.c b/builtin/fast-export.c
 index b6f623e..8ed41b4 100644
 --- a/builtin/fast-export.c
 +++ b/builtin/fast-export.c
 @@ -673,6 +673,19 @@ static void import_marks(char *input_file)
  fclose(f);
 }
 
 +static void handle_deletes(void)
 +{
 + int i;
 + for (i = 0; i  refspecs_nr; i++) {
 + struct refspec *refspec = refspecs[i];
 + if (*refspec-src)
 + continue;
 +
 + printf(reset %s\nfrom %s\n\n,
 + refspec-dst, sha1_to_hex(null_sha1));
 
 If I understand it right, this issues a reset command in the fast-import 
 stream, resetting a ref to an all-zero SHA1. I had a look at the 
 git-fast-import documentation, but I found that it does not explicitly cover 
 this case. In particular, the reset command does not specify that an 
 all-zero SHA1 should be treated as delete this ref.
 
 That's what the previous patch does.

Right *facepalm*.

But then this should be documented in git-fast-import.txt, shouldn't it?

 
 On the other hand, the docs for reset seem to indicate that one can omit 
 the from part, although I couldn't tell for sure what that would mean, 
 either.
 
 It means something different.

Yeah, I figured that -- just wanted to point out that this, too, is not very 
clear in the documentation and should be improved (not saying that I expect you 
to do that, just pointing it out).



signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: [PATCH 16/16] add: avoid yoda conditions

2013-10-31 Thread Martin von Zweigbergk
I was recently confused by the yoda condition in this block of code from [1]

+ for (i = 0; i  revs.nr; i++)
+ if (bases-item-object == revs.commit[i]-object)
+ break; /* found */
+ if (revs.nr = i)

I think I was particularly surprised because it came so soon after the
i  revs.nr. I didn't bother commenting because it seemed too
subjective and the code base has tons of these. Something as simple as

  git grep '[0-9] []' *.c

finds a bunch (probably with lots of false positives and negatives).

I guess what I'm trying to say is that either we accept them and get
used to reading them without being surprised, or we can change a bit
more than one at a time perhaps? I understand that this was an
occurrence you just happened to run into, and I'm not saying that a
patch has to deal with _all_ occurrences. I'm more just wondering if
we want mention our position, whatever it is, in CodingGuidelines.

Martin

[1] http://thread.gmane.org/gmane.comp.version-control.git/236252/focus=236716

On Thu, Oct 31, 2013 at 2:25 AM, Felipe Contreras
felipe.contre...@gmail.com wrote:
 Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
 ---
  builtin/add.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/builtin/add.c b/builtin/add.c
 index 226f758..9b30356 100644
 --- a/builtin/add.c
 +++ b/builtin/add.c
 @@ -429,7 +429,7 @@ int cmd_add(int argc, const char **argv, const char 
 *prefix)
 argc--;
 argv++;

 -   if (0 = addremove_explicit)
 +   if (addremove_explicit = 0)
 addremove = addremove_explicit;
 else if (take_worktree_changes  ADDREMOVE_DEFAULT)
 addremove = 0; /* -u was given but not -A */
 --
 1.8.4.2+fc1

 --
 To unsubscribe from this list: send the line unsubscribe git in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 09/10] fast-export: add support to delete refs

2013-10-31 Thread Felipe Contreras
On Thu, Oct 31, 2013 at 1:47 PM, Max Horn m...@quendi.de wrote:

 On 31.10.2013, at 20:41, Felipe Contreras felipe.contre...@gmail.com wrote:

 On Thu, Oct 31, 2013 at 1:29 PM, Max Horn m...@quendi.de wrote:
 Actually, I just noticed one thing that I *do* have a question about:

 On 31.10.2013, at 10:36, Felipe Contreras felipe.contre...@gmail.com 
 wrote:

 Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
 ---
 builtin/fast-export.c  | 14 ++
 t/t9350-fast-export.sh | 11 +++
 2 files changed, 25 insertions(+)

 diff --git a/builtin/fast-export.c b/builtin/fast-export.c
 index b6f623e..8ed41b4 100644
 --- a/builtin/fast-export.c
 +++ b/builtin/fast-export.c
 @@ -673,6 +673,19 @@ static void import_marks(char *input_file)
  fclose(f);
 }

 +static void handle_deletes(void)
 +{
 + int i;
 + for (i = 0; i  refspecs_nr; i++) {
 + struct refspec *refspec = refspecs[i];
 + if (*refspec-src)
 + continue;
 +
 + printf(reset %s\nfrom %s\n\n,
 + refspec-dst, sha1_to_hex(null_sha1));

 If I understand it right, this issues a reset command in the fast-import 
 stream, resetting a ref to an all-zero SHA1. I had a look at the 
 git-fast-import documentation, but I found that it does not explicitly 
 cover this case. In particular, the reset command does not specify that 
 an all-zero SHA1 should be treated as delete this ref.

 That's what the previous patch does.

 Right *facepalm*.

 But then this should be documented in git-fast-import.txt, shouldn't it?

It is... in the previous patch.

-- 
Felipe Contreras
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 16/16] add: avoid yoda conditions

2013-10-31 Thread Felipe Contreras
On Thu, Oct 31, 2013 at 1:48 PM, Martin von Zweigbergk
martinv...@gmail.com wrote:

 I guess what I'm trying to say is that either we accept them and get
 used to reading them without being surprised, or we can change a bit
 more than one at a time perhaps? I understand that this was an
 occurrence you just happened to run into, and I'm not saying that a
 patch has to deal with _all_ occurrences. I'm more just wondering if
 we want mention our position, whatever it is, in CodingGuidelines.

Yes, I'm all in favor of updating CodingGuidelines with that.

-- 
Felipe Contreras
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 03/16] pull: cleanup documentation

2013-10-31 Thread Felipe Contreras
On Thu, Oct 31, 2013 at 1:00 PM, Junio C Hamano gits...@pobox.com wrote:
 Felipe Contreras felipe.contre...@gmail.com writes:

 On Thu, Oct 31, 2013 at 12:11 PM, Junio C Hamano gits...@pobox.com wrote:
 Felipe Contreras felipe.contre...@gmail.com writes:

 --- a/Documentation/git-pull.txt
 +++ b/Documentation/git-pull.txt
 @@ -39,7 +39,7 @@ Assume the following history exists and the current 
 branch is
  `master`:

  
 -   A---B---C master on origin
 +   A---B---C origin/master
/
  D---E---F---G master
  

 This change is wrong; the illustration depicts the distributed world
 (i.e. a fetch has not happened yet).

 That is an irrelevant implementation detail, specially at this high
 level. In the user's mind origin/master means master on origin.

 You are wrong.  In the user's mind, origin/master means the commit
 that used to be at master on origin, and the point of this
 illustration is to make them understand that they live in a
 distributed world, where their last observation will go stale over
 time.

Wrong. That would make sense in 'git fetch', but here the point of the
illustration is to make them understand what 'git pull' will do,
namely a merge.

Which refs point to C at which points in time irrelevant information,
the user wants to know that 'git pull' will create a merge.

 If you want to be pedantic, this is the reality:

   
   D---E---F---G master
   

 You are wrong again.  The reality is more like this:

   origin/master in your repository
   |
   v
   A---B---C master at origin
  /
 D---E---F---G master in your repository

 if you really want to write origin/master somewhere in this
 illustration.

Wrong. You probably mean:


  A---B---C master on origin
 /
D---E origin/master
 \
  F---G master


But 'master on origin' doesn't exist in reality according to you, so:


D---E origin/master
 \
  F---G master


-- 
Felipe Contreras
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 06/16] shortlog: add missing declaration

2013-10-31 Thread Junio C Hamano
Felipe Contreras felipe.contre...@gmail.com writes:

 On Thu, Oct 31, 2013 at 1:05 PM, Junio C Hamano gits...@pobox.com wrote:
 Felipe Contreras felipe.contre...@gmail.com writes:

 Otherwise we would have to include commit.h.

 Was there a reason why commit.h is not included here, just like
 revision.h would include diff.h, so that users of shortlog.h do not
 have to worry about including commit.h themselves?

 Because you can't do:

 struct diff_options;
 struct diff_options diffopt;

 The storage size is not known, but you can do:

 struct diff_options;
 struct diff_options *diffopt;

But so can you do

struct diff_options *diffopt;

without the declaration, no?  That is:

$ cat x.c \EOF
struct foo {
struct bar *ptr;
};

int foo_is_null(struct foo *foo)
{
return foo == 0;
}
EOF
$ gcc -Wall -c x.c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Help creating git alias

2013-10-31 Thread Eugene Sajine
On Thu, Oct 31, 2013 at 3:41 PM, Junio C Hamano gits...@pobox.com wrote:
 Eugene Sajine eugu...@gmail.com writes:

 One note: i tried the ${GIT_PREFIX:-.}  and ${GIT_PREFIX} and it seems
 to give the same results. What is the expected difference here?

 GIT_PREFIX may be an empty string when you run from the top-level,
 in which case you would end up with cd  ... and end up working
 in your $HOME.



got it! thank you!

Eugene
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 03/16] pull: cleanup documentation

2013-10-31 Thread Junio C Hamano
Felipe Contreras felipe.contre...@gmail.com writes:

 On Thu, Oct 31, 2013 at 1:00 PM, Junio C Hamano gits...@pobox.com wrote:
 Felipe Contreras felipe.contre...@gmail.com writes:

 On Thu, Oct 31, 2013 at 12:11 PM, Junio C Hamano gits...@pobox.com wrote:
 Felipe Contreras felipe.contre...@gmail.com writes:

 --- a/Documentation/git-pull.txt
 +++ b/Documentation/git-pull.txt
 @@ -39,7 +39,7 @@ Assume the following history exists and the current 
 branch is
  `master`:

  
 -   A---B---C master on origin
 +   A---B---C origin/master
/
  D---E---F---G master
  

 This change is wrong; the illustration depicts the distributed world
 (i.e. a fetch has not happened yet).

 That is an irrelevant implementation detail, specially at this high
 level. In the user's mind origin/master means master on origin.

 You are wrong.  In the user's mind, origin/master means the commit
 that used to be at master on origin, and the point of this
 illustration is to make them understand that they live in a
 distributed world, where their last observation will go stale over
 time.

 Wrong. That would make sense in 'git fetch', but here the point of the
 illustration is to make them understand what 'git pull' will do,
 namely a merge.

 Which refs point to C at which points in time irrelevant information,
 the user wants to know that 'git pull' will create a merge.

Merge with what, and how do the users know what will be merged?

Think.

The users need to learn that origin/master they were told to use
with git log origin/master.. etc. trails reality, git fetch is
how they can get them in sync, and the reason they do not need to
run git fetch separately when they git pull is because it is run
for them internally.

That is what the illustration and the paragraph that follows teach
them.

I've said enough on this.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 16/16] add: avoid yoda conditions

2013-10-31 Thread Junio C Hamano
Martin von Zweigbergk martinv...@gmail.com writes:

 I was recently confused by the yoda condition in this block of code from [1]

 + for (i = 0; i  revs.nr; i++)
 + if (bases-item-object == revs.commit[i]-object)
 + break; /* found */
 + if (revs.nr = i)

 I think I was particularly surprised because it came so soon after the
 i  revs.nr. I didn't bother commenting because it seemed too
 subjective and the code base has tons of these.

That follows visual/textual order should follow the actual
ordering principle.  Think of a number-line you learn in elementary
school arithmetic class, and try to place revs.nr and i on it.

I agree that there is no justification to write if 0 == something,
when if something == 0 suffices.  The latter reads better and that
is why the phrase yoda condition was invented.

But the situation is different when both sides are not constants,
and especially when  and = are involved..
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 16/16] add: avoid yoda conditions

2013-10-31 Thread Felipe Contreras
On Thu, Oct 31, 2013 at 2:31 PM, Junio C Hamano gits...@pobox.com wrote:

 I agree that there is no justification to write if 0 == something,
 when if something == 0 suffices.  The latter reads better and that
 is why the phrase yoda condition was invented.

 But the situation is different when both sides are not constants,
 and especially when  and = are involved..

To me revs.nr is virtually a constant, I'm comparing i to revs.nr, not
the other way around.

I believe I explained this already, but here it goes again:

if (1.60  john.size)

This makes no sense, if 1.69 is smaller than john?

The situation doesn't change when you use a variable:

if (size_limit  john.size)

Translates to if size limit is smaller than john, and still makes no sense.

-- 
Felipe Contreras
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


  1   2   >