[PATCH try2 1/2] branch: trivial cleanup

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

Signed-off-by: Felipe Contreras 
---
 builtin/branch.c | 19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/builtin/branch.c b/builtin/branch.c
index 0836890..ac17b18 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -425,16 +425,15 @@ static void fill_tracking_info(struct strbuf *stat, const 
char *branch_name,
struct strbuf fancy = STRBUF_INIT;
 
if (!stat_tracking_info(branch, &ours, &theirs)) {
-   if (branch && branch->merge && branch->merge[0]->dst &&
-   show_upstream_ref) {
-   ref = shorten_unambiguous_ref(branch->merge[0]->dst, 0);
-   if (want_color(branch_use_color))
-   strbuf_addf(stat, "[%s%s%s] ",
-   
branch_get_color(BRANCH_COLOR_UPSTREAM),
-   ref, 
branch_get_color(BRANCH_COLOR_RESET));
-   else
-   strbuf_addf(stat, "[%s] ", ref);
-   }
+   if (!branch || !branch->merge || !branch->merge[0]->dst || 
!show_upstream_ref)
+   return;
+   ref = shorten_unambiguous_ref(branch->merge[0]->dst, 0);
+   if (want_color(branch_use_color))
+   strbuf_addf(stat, "[%s%s%s] ",
+   branch_get_color(BRANCH_COLOR_UPSTREAM),
+   ref, 
branch_get_color(BRANCH_COLOR_RESET));
+   else
+   strbuf_addf(stat, "[%s] ", ref);
return;
}
 
-- 
1.8.4-fc

--
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 try2 0/2] branch: improve verbose option

2013-10-12 Thread Felipe Contreras
This has been discussed before:

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

but in the spirit of the perfect being the enemy of the good, nothing got done.

This series makes 'git branch -v' much faster, and gives us the most important
information; the configured upstream tracking branch. Showing ahead/behind is
not as important, specially considering that currently 'git branch -v' doesn't
show the branch we are comparing the ahead/behind to.

Strictly speaking it's a regression, but nobody would complain, and if somebody
does, it should be easy to revert if needed.

Felipe Contreras (2):
  branch: trivial cleanup
  branch: reorganize verbose options

 builtin/branch.c | 33 +++--
 t/t6040-tracking-info.sh |  8 
 2 files changed, 19 insertions(+), 22 deletions(-)

-- 
1.8.4-fc

--
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 try2 2/2] branch: reorganize verbose options

2013-10-12 Thread Felipe Contreras
Showing the upstream tracking branch is more important than how many
commits are ahead/behind, so now 'git branch -v' shows the upstream, but
not the tracking info, and 'git branch -vv' shows all information (as
before).

Signed-off-by: Felipe Contreras 
---
 builtin/branch.c | 22 ++
 t/t6040-tracking-info.sh |  8 
 2 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/builtin/branch.c b/builtin/branch.c
index ac17b18..baa1d31 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -417,15 +417,15 @@ static int ref_cmp(const void *r1, const void *r2)
 }
 
 static void fill_tracking_info(struct strbuf *stat, const char *branch_name,
-   int show_upstream_ref)
+   int show_tracking)
 {
int ours, theirs;
char *ref = NULL;
struct branch *branch = branch_get(branch_name);
struct strbuf fancy = STRBUF_INIT;
 
-   if (!stat_tracking_info(branch, &ours, &theirs)) {
-   if (!branch || !branch->merge || !branch->merge[0]->dst || 
!show_upstream_ref)
+   if (!show_tracking || !stat_tracking_info(branch, &ours, &theirs)) {
+   if (!branch || !branch->merge || !branch->merge[0]->dst)
return;
ref = shorten_unambiguous_ref(branch->merge[0]->dst, 0);
if (want_color(branch_use_color))
@@ -437,15 +437,13 @@ static void fill_tracking_info(struct strbuf *stat, const 
char *branch_name,
return;
}
 
-   if (show_upstream_ref) {
-   ref = shorten_unambiguous_ref(branch->merge[0]->dst, 0);
-   if (want_color(branch_use_color))
-   strbuf_addf(&fancy, "%s%s%s",
-   branch_get_color(BRANCH_COLOR_UPSTREAM),
-   ref, 
branch_get_color(BRANCH_COLOR_RESET));
-   else
-   strbuf_addstr(&fancy, ref);
-   }
+   ref = shorten_unambiguous_ref(branch->merge[0]->dst, 0);
+   if (want_color(branch_use_color))
+   strbuf_addf(&fancy, "%s%s%s",
+   branch_get_color(BRANCH_COLOR_UPSTREAM),
+   ref, branch_get_color(BRANCH_COLOR_RESET));
+   else
+   strbuf_addstr(&fancy, ref);
 
if (!ours) {
if (ref)
diff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh
index ec2b516..86e80eb 100755
--- a/t/t6040-tracking-info.sh
+++ b/t/t6040-tracking-info.sh
@@ -36,10 +36,10 @@ test_expect_success setup '
 
 script='s/^..\(b.\)[0-9a-f]*\[\([^]]*\)\].*/\1 \2/p'
 cat >expect <<\EOF
-b1 ahead 1, behind 1
-b2 ahead 1, behind 1
-b3 behind 1
-b4 ahead 2
+b1 origin/master
+b2 origin/master
+b3 origin/master
+b4 origin/master
 EOF
 
 test_expect_success 'branch -v' '
-- 
1.8.4-fc

--
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 v4 4/7] pull: add merge-ff-only option

2013-10-12 Thread Felipe Contreras
It is very typical for Git newcomers to inadvertently create merges and
worst; inadvertently pushing them. This is one of the reasons many
experienced users prefer to avoid 'git pull', and recommend newcomers to
avoid it as well.

To avoid these problems and keep 'git pull' useful, it has been
suggested that 'git pull' barfs by default if the merge is
non-fast-forward, which unfortunately would break backwards
compatibility.

This patch leaves everything in place to enable this new mode, but it
only gets enabled if the user specifically configures it; pull.mode =
merge-ff-only.

Later on this mode can be enabled by default (e.g. in v2.0).

For the full discussion you can read:

http://thread.gmane.org/gmane.comp.version-control.git/225146/focus=225305

Signed-off-by: Felipe Contreras 
---
 Documentation/config.txt |  8 +---
 git-pull.sh  | 13 +
 t/t5520-pull.sh  | 36 
 3 files changed, 54 insertions(+), 3 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 9489a59..13635e0 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1822,9 +1822,11 @@ pretty.::
 
 pull.mode::
When "git pull" is run, this determines if it would either merge or
-   rebase the fetched branch. The possible values are 'merge' and
-   'rebase'. See "branch..pullmode" for doing this in a non
-   branch-specific manner.
+   rebase the fetched branch. The possible values are 'merge',
+   'rebase', and 'merge-ff-only'. If 'merge-ff-only' is specified, the
+   merge will only succeed if it's fast-forward. See
+   "branch..pullmode" for doing this in a non branch-specific
+   manner.
 +
 *NOTE*: this is a possibly dangerous operation; do *not* use
 it unless you understand the implications (see linkgit:git-rebase[1]
diff --git a/git-pull.sh b/git-pull.sh
index fbb8a9b..6e6b887 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -62,6 +62,7 @@ then
echo "Please use pull.mode and branch..pullmode instead."
fi
 fi
+test -z "$mode" && mode=merge
 dry_run=
 while :
 do
@@ -282,6 +283,18 @@ case "$merge_head" in
die "$(gettext "Cannot rebase onto multiple branches")"
fi
;;
+*)
+   # check if a non-fast-foward merge would be needed
+   merge_head=${merge_head% }
+   if test "$mode" = merge-ff-only -a -z 
"$no_ff$ff_only${squash#--no-squash}" &&
+   test -n "$orig_head" &&
+   ! git merge-base --is-ancestor "$orig_head" "$merge_head" &&
+   ! git merge-base --is-ancestor "$merge_head" "$orig_head"
+   then
+   die "$(gettext "The pull was not fast-forward, please either 
merge or rebase.
+If unsure, run 'git pull --merge'.")"
+   fi
+   ;;
 esac
 
 # Pulling into unborn branch: a shorthand for branching off
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index 978a3c1..798ae2f 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -310,4 +310,40 @@ test_expect_success 'branch.to-rebase.pullmode should 
override pull.mode' '
test new = $(git show HEAD:file2)
 '
 
+test_expect_success 'git pull fast-forward' '
+   test_when_finished "git checkout master && git branch -D other test" &&
+   test_config pull.mode merge-ff-only &&
+   git checkout -b other master &&
+   >new &&
+   git add new &&
+   git commit -m new &&
+   git checkout -b test -t other &&
+   git reset --hard master &&
+   git pull
+'
+
+test_expect_success 'git pull non-fast-forward' '
+   test_when_finished "git checkout master && git branch -D other test" &&
+   test_config pull.mode merge-ff-only &&
+   git checkout -b other master^ &&
+   >new &&
+   git add new &&
+   git commit -m new &&
+   git checkout -b test -t other &&
+   git reset --hard master &&
+   test_must_fail git pull
+'
+
+test_expect_success 'git pull non-fast-forward (merge)' '
+   test_when_finished "git checkout master && git branch -D other test" &&
+   test_config pull.mode merge-ff-only &&
+   git checkout -b other master^ &&
+   >new &&
+   git add new &&
+   git commit -m new &&
+   git checkout -b test -t other &&
+   git reset --hard master &&
+   git pull --merge
+'
+
 test_done
-- 
1.8.4-fc

--
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 v4 5/7] pull: add warning on non-ff merges

2013-10-12 Thread Felipe Contreras
To prepare our uses for the upcoming changes we should warn them and let
them know that they will need to specify a merge or a rebase in the
future (when a non-fast-forward situation arises). Also, let them know
we fallback to 'git pull --merge', so when the obsoletion of this mode
comes, they know what to type without interrupting or changing their
workflow.

Signed-off-by: Felipe Contreras 
---
 git-pull.sh | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/git-pull.sh b/git-pull.sh
index 6e6b887..d1b07d8 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -62,7 +62,7 @@ then
echo "Please use pull.mode and branch..pullmode instead."
fi
 fi
-test -z "$mode" && mode=merge
+test -z "$mode" && mode=default
 dry_run=
 while :
 do
@@ -286,13 +286,22 @@ case "$merge_head" in
 *)
# check if a non-fast-foward merge would be needed
merge_head=${merge_head% }
-   if test "$mode" = merge-ff-only -a -z 
"$no_ff$ff_only${squash#--no-squash}" &&
+   if test -z "$no_ff$ff_only${squash#--no-squash}" &&
test -n "$orig_head" &&
! git merge-base --is-ancestor "$orig_head" "$merge_head" &&
! git merge-base --is-ancestor "$merge_head" "$orig_head"
then
-   die "$(gettext "The pull was not fast-forward, please either 
merge or rebase.
+   case "$mode" in
+   merge-ff-only)
+   die "$(gettext "The pull was not fast-forward, please 
either merge or rebase.
 If unsure, run 'git pull --merge'.")"
+   ;;
+   default)
+   echo "$(gettext "warning: the pull was not 
fast-forward, in the future you would have to choose
+a merge or a rebase, falling back to old style for now (git pull --merge).
+Read 'git pull --help' for more information.")" >&2
+   ;;
+   esac
fi
;;
 esac
-- 
1.8.4-fc

--
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 v4 3/7] pull: add --merge option

2013-10-12 Thread Felipe Contreras
Also, deprecate --no-rebase since there's no need for it any more.

Signed-off-by: Felipe Contreras 
---
 Documentation/git-pull.txt | 8 ++--
 git-pull.sh| 6 +-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt
index 991352f..e09f004 100644
--- a/Documentation/git-pull.txt
+++ b/Documentation/git-pull.txt
@@ -119,8 +119,12 @@ It rewrites history, which does not bode well when you
 published that history already.  Do *not* use this option
 unless you have read linkgit:git-rebase[1] carefully.
 
---no-rebase::
-   Override earlier --rebase.
+-m::
+--merge::
+   Force a merge.
++
+See `pull.mode`, `branch..pullmode` in linkgit:git-config[1] if you want
+to make `git pull` always use `--merge`.
 
 Options related to fetching
 ~~~
diff --git a/git-pull.sh b/git-pull.sh
index f53d193..fbb8a9b 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -127,8 +127,12 @@ do
-r|--r|--re|--reb|--reba|--rebas|--rebase)
mode=rebase
;;
+   -m|--m|--me|--mer|--merg|--merge)
+   mode=merge
+   ;;
--no-r|--no-re|--no-reb|--no-reba|--no-rebas|--no-rebase)
-   mode=
+   mode=merge
+   echo "--no-rebase is deprecated, please use --merge instead"
;;
--recurse-submodules)
recurse_submodules=--recurse-submodules
-- 
1.8.4-fc

--
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 v4 1/7] pull: rename pull.rename to pull.mode

2013-10-12 Thread Felipe Contreras
Also 'branch..rebase' to 'branch..pullmode'.

This way 'pull.mode' can be set to 'merge', and the default can be
something else.

The old configurations still work, but get deprecated.

Signed-off-by: Felipe Contreras 
---
 Documentation/config.txt   | 22 +++---
 Documentation/git-pull.txt |  2 +-
 branch.c   |  4 ++--
 git-pull.sh| 18 --
 t/t3200-branch.sh  | 40 
 t/t5520-pull.sh| 26 ++
 t/t5601-clone.sh   |  4 ++--
 7 files changed, 78 insertions(+), 38 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index ec57a15..9489a59 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -706,7 +706,7 @@ branch.autosetupmerge::
 branch.autosetuprebase::
When a new branch is created with 'git branch' or 'git checkout'
that tracks another branch, this variable tells Git to set
-   up pull to rebase instead of merge (see "branch..rebase").
+   up pull to rebase instead of merge (see "branch..pullmode").
When `never`, rebase is never automatically set to true.
When `local`, rebase is set to true for tracked branches of
other local branches.
@@ -760,11 +760,11 @@ branch..mergeoptions::
option values containing whitespace characters are currently not
supported.
 
-branch..rebase::
-   When true, rebase the branch  on top of the fetched branch,
-   instead of merging the default branch from the default remote when
-   "git pull" is run. See "pull.rebase" for doing this in a non
-   branch-specific manner.
+branch..pullmode::
+   When "git pull" is run, this determines if it would either merge or
+   rebase the fetched branch. The possible values are 'merge' and
+   'rebase'. See "pull.mode" for doing this in a non branch-specific
+   manner.
 +
 *NOTE*: this is a possibly dangerous operation; do *not* use
 it unless you understand the implications (see linkgit:git-rebase[1]
@@ -1820,11 +1820,11 @@ pretty.::
Note that an alias with the same name as a built-in format
will be silently ignored.
 
-pull.rebase::
-   When true, rebase branches on top of the fetched branch, instead
-   of merging the default branch from the default remote when "git
-   pull" is run. See "branch..rebase" for setting this on a
-   per-branch basis.
+pull.mode::
+   When "git pull" is run, this determines if it would either merge or
+   rebase the fetched branch. The possible values are 'merge' and
+   'rebase'. See "branch..pullmode" for doing this in a non
+   branch-specific manner.
 +
 *NOTE*: this is a possibly dangerous operation; do *not* use
 it unless you understand the implications (see linkgit:git-rebase[1]
diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt
index 6ef8d59..991352f 100644
--- a/Documentation/git-pull.txt
+++ b/Documentation/git-pull.txt
@@ -109,7 +109,7 @@ include::merge-options.txt[]
fetched, the rebase uses that information to avoid rebasing
non-local changes.
 +
-See `pull.rebase`, `branch..rebase` and `branch.autosetuprebase` in
+See `pull.mode`, `branch..pullmode` and `branch.autosetuprebase` in
 linkgit:git-config[1] if you want to make `git pull` always use
 `--rebase` instead of merging.
 +
diff --git a/branch.c b/branch.c
index c5c6984..c6b70c2 100644
--- a/branch.c
+++ b/branch.c
@@ -71,8 +71,8 @@ void install_branch_config(int flag, const char *local, const 
char *origin, cons
 
if (rebasing) {
strbuf_reset(&key);
-   strbuf_addf(&key, "branch.%s.rebase", local);
-   git_config_set(key.buf, "true");
+   strbuf_addf(&key, "branch.%s.pullmode", local);
+   git_config_set(key.buf, "rebase");
}
strbuf_release(&key);
 
diff --git a/git-pull.sh b/git-pull.sh
index f0df41c..8363647 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -43,10 +43,24 @@ log_arg= verbosity= progress= recurse_submodules= 
verify_signatures=
 merge_args= edit=
 curr_branch=$(git symbolic-ref -q HEAD)
 curr_branch_short="${curr_branch#refs/heads/}"
-rebase=$(git config --bool branch.$curr_branch_short.rebase)
+mode=$(git config branch.${curr_branch_short}.pullmode)
+if test -z "$mode"
+then
+   mode=$(git config pull.mode)
+fi
+test "$mode" = 'rebase' && rebase="true"
 if test -z "$rebase"
 then
-   rebase=$(git config --bool pull.rebase)
+   rebase=$(git config --bool branch.$curr_branch_short.rebase)
+   if test -z "$rebase"
+   then
+   rebase=$(git config --bool pull.rebase)
+   fi
+   if test "$rebase" = 'true'
+   then
+   echo "The configurations pull.rebase and branch..rebase 
are deprecated."
+   echo "Please use pull.mode and branch..pullmode instead."
+   fi
 fi
 dry_run=
 while :
diff --git a/t/t3200-branc

[PATCH v4 7/7] pull: add documentation about non-ff merges

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 Documentation/git-pull.txt | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt
index 6d55737..b4053a8 100644
--- a/Documentation/git-pull.txt
+++ b/Documentation/git-pull.txt
@@ -23,6 +23,7 @@ More precisely, 'git pull' runs 'git fetch' with the given
 parameters and calls 'git merge' to merge the retrieved branch
 heads into the current branch.
 With `--rebase`, it runs 'git rebase' instead of 'git merge'.
+With `--merge`, it forces the merge, even if it's non-fast forward.
 
  should be the name of a remote repository as
 passed to linkgit:git-fetch[1].   can name an
@@ -41,9 +42,26 @@ Assume the following history exists and the current branch is
 
  A---B---C origin/master
 /
+D---E master
+
+
+Then `git pull` will merge in a fast-foward way up to the new master.
+
+
+D---E---A---B---C master, origin/master
+
+
+However, a non-fast-foward case looks very different.
+
+
+ A---B---C origin/master
+/
 D---E---F---G master
 
 
+In the future, `git pull` will fail on these situations, however, most likely
+you would want to force a merge, which you can do with `git pull --merge`.
+
 Then "`git pull`" will fetch and replay the changes from the remote
 `master` branch since it diverged from the local `master` (i.e., `E`)
 until its current commit (`C`) on top of `master` and record the
-- 
1.8.4-fc

--
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 v4 0/7] Reject non-ff pulls by default

2013-10-12 Thread Felipe Contreras
Minor changes since v3.

Junio already sent a similar patch, but I think this is simpler.

It is very typical for Git newcomers to inadvertently create merges and worst:
inadvertently pushing them. This is one of the reasons many experienced users
prefer to avoid 'git pull', and recommend newcomers to avoid it as well.

To avoid these problems and keep 'git pull' useful, it has been suggested
that 'git pull' barfs by default if the merge is non-fast-forward, which
unfortunately would break backwards compatibility.

This patch series leaves everything in place to enable this new mode, but it
only gets enabled if the user specifically configures it; pull.mode =
merge-ff-only.

Later on this mode can be enabled by default (e.g. in v2.0).

To achieve that first some configurations are renamed: for example: pull.rebase
=> pull.mode = rebase, but the old ones remain functional, thus there are no
functional changes.

Then the new mode 'merge-ff-only' is added, but not enabled by default, and
finally, a warning is added so the users will know what to do when the new
mode is indeed enabled by default.

Diff from last version:

--- a/git-pull.sh
+++ b/git-pull.sh
@@ -293,12 +293,13 @@ case "$merge_head" in
then
case "$mode" in
merge-ff-only)
-   die "The pull was not fast-forward, please either merge 
or rebase."
+   die "$(gettext "The pull was not fast-forward, please 
either merge or rebase.
+If unsure, run 'git pull --merge'.")"
;;
default)
-   say "The pull was not fast-forward, in the future you 
would have to choose
+   echo "$(gettext "warning: the pull was not 
fast-forward, in the future you would have to choose
 a merge or a rebase, falling back to old style for now (git pull --merge).
-Read 'git pull --help' for more information."
+Read 'git pull --help' for more information.")" >&2
;;
esac
fi

Felipe Contreras (7):
  pull: rename pull.rename to pull.mode
  pull: refactor $rebase variable into $mode
  pull: add --merge option
  pull: add merge-ff-only option
  pull: add warning on non-ff merges
  pull: cleanup documentation
  pull: add documentation about non-ff merges

 Documentation/config.txt   | 24 +
 Documentation/git-pull.txt | 32 +++
 branch.c   |  4 +--
 git-pull.sh| 64 +-
 t/t3200-branch.sh  | 40 ++---
 t/t5520-pull.sh| 62 
 t/t5601-clone.sh   |  4 +--
 7 files changed, 178 insertions(+), 52 deletions(-)

-- 
1.8.4-fc

--
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 v4 6/7] pull: cleanup documentation

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

Signed-off-by: Felipe Contreras 
---
 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 e09f004..6d55737 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-fc

--
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 v4 2/7] pull: refactor $rebase variable into $mode

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 git-pull.sh | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/git-pull.sh b/git-pull.sh
index 8363647..f53d193 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -48,8 +48,7 @@ if test -z "$mode"
 then
mode=$(git config pull.mode)
 fi
-test "$mode" = 'rebase' && rebase="true"
-if test -z "$rebase"
+if test -z "$mode"
 then
rebase=$(git config --bool branch.$curr_branch_short.rebase)
if test -z "$rebase"
@@ -58,6 +57,7 @@ then
fi
if test "$rebase" = 'true'
then
+   mode="rebase"
echo "The configurations pull.rebase and branch..rebase 
are deprecated."
echo "Please use pull.mode and branch..pullmode instead."
fi
@@ -125,10 +125,10 @@ do
merge_args="$merge_args$xx "
;;
-r|--r|--re|--reb|--reba|--rebas|--rebase)
-   rebase=true
+   mode=rebase
;;
--no-r|--no-re|--no-reb|--no-reba|--no-rebas|--no-rebase)
-   rebase=false
+   mode=
;;
--recurse-submodules)
recurse_submodules=--recurse-submodules
@@ -171,7 +171,7 @@ error_on_no_merge_candidates () {
esac
done
 
-   if test true = "$rebase"
+   if test "$mode" = rebase
then
op_type=rebase
op_prep=against
@@ -185,7 +185,7 @@ error_on_no_merge_candidates () {
remote=$(git config "branch.$curr_branch.remote")
 
if [ $# -gt 1 ]; then
-   if [ "$rebase" = true ]; then
+   if [ "$mode" = rebase ]; then
printf "There is no candidate for rebasing against "
else
printf "There are no candidates for merging "
@@ -208,7 +208,7 @@ error_on_no_merge_candidates () {
exit 1
 }
 
-test true = "$rebase" && {
+test "$mode" = rebase && {
if ! git rev-parse -q --verify HEAD >/dev/null
then
# On an unborn branch
@@ -273,7 +273,7 @@ case "$merge_head" in
then
die "$(gettext "Cannot merge multiple branches into empty 
head")"
fi
-   if test true = "$rebase"
+   if test "$mode" = rebase
then
die "$(gettext "Cannot rebase onto multiple branches")"
fi
@@ -294,7 +294,7 @@ then
exit
 fi
 
-if test true = "$rebase"
+if test "$mode" = rebase
 then
o=$(git show-branch --merge-base $curr_branch $merge_head $oldremoteref)
if test "$oldremoteref" = "$o"
@@ -304,8 +304,8 @@ then
 fi
 
 merge_name=$(git fmt-merge-msg $log_arg <"$GIT_DIR/FETCH_HEAD") || exit
-case "$rebase" in
-true)
+case "$mode" in
+rebase)
eval="git-rebase $diffstat $strategy_args $merge_args $verbosity"
eval="$eval --onto $merge_head ${oldremoteref:-$merge_head}"
;;
-- 
1.8.4-fc

--
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 v2 0/5] remote-helpers: test reorganization

2013-10-12 Thread Felipe Contreras
Now we use PYTHON_PATH properly, and also we are able to do:

  make -C contrib/remote-helpers install

Felipe Contreras (5):
  remote-helpers: generate scripts
  build: fix installation of scripts
  remote-helpers: rename tests
  remote-helpers: allow direct test execution
  remote-helpers: add exec-path links

 Makefile |   10 +-
 contrib/remote-helpers/.gitignore|2 +
 contrib/remote-helpers/Makefile  |   27 +-
 contrib/remote-helpers/git-remote-bzr|  960 ---
 contrib/remote-helpers/git-remote-bzr.py |  960 +++
 contrib/remote-helpers/git-remote-hg | 1220 --
 contrib/remote-helpers/git-remote-hg.py  | 1220 ++
 contrib/remote-helpers/test-bzr.sh   |  361 -
 contrib/remote-helpers/test-bzr.t|  362 +
 contrib/remote-helpers/test-hg-bidi.sh   |  240 --
 contrib/remote-helpers/test-hg-bidi.t|  241 ++
 contrib/remote-helpers/test-hg-hg-git.sh |  527 -
 contrib/remote-helpers/test-hg-hg-git.t  |  528 +
 contrib/remote-helpers/test-hg.sh|  692 -
 contrib/remote-helpers/test-hg.t |  693 +
 15 files changed, 4034 insertions(+), 4009 deletions(-)
 create mode 100644 contrib/remote-helpers/.gitignore
 delete mode 100755 contrib/remote-helpers/git-remote-bzr
 create mode 100755 contrib/remote-helpers/git-remote-bzr.py
 delete mode 100755 contrib/remote-helpers/git-remote-hg
 create mode 100755 contrib/remote-helpers/git-remote-hg.py
 delete mode 100755 contrib/remote-helpers/test-bzr.sh
 create mode 100755 contrib/remote-helpers/test-bzr.t
 delete mode 100755 contrib/remote-helpers/test-hg-bidi.sh
 create mode 100755 contrib/remote-helpers/test-hg-bidi.t
 delete mode 100755 contrib/remote-helpers/test-hg-hg-git.sh
 create mode 100755 contrib/remote-helpers/test-hg-hg-git.t
 delete mode 100755 contrib/remote-helpers/test-hg.sh
 create mode 100755 contrib/remote-helpers/test-hg.t

-- 
1.8.4-fc

--
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 v3 try2] build: add default aliases

2013-10-12 Thread Felipe Contreras
For now simply add a few common aliases.

  co = checkout
  ci = commit
  rb = rebase
  st = status

Signed-off-by: Felipe Contreras 
---
 Documentation/git-checkout.txt | 5 +
 Documentation/git-commit.txt   | 5 +
 Documentation/git-rebase.txt   | 5 +
 Documentation/git-status.txt   | 5 +
 config.c   | 5 +
 5 files changed, 25 insertions(+)

diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index ca118ac..7597813 100644
--- a/Documentation/git-checkout.txt
+++ b/Documentation/git-checkout.txt
@@ -14,6 +14,11 @@ SYNOPSIS
 'git checkout' [-f|--ours|--theirs|-m|--conflict=

[PATCH v2 2/5] build: fix installation of scripts

2013-10-12 Thread Felipe Contreras
They need the gitexecdir.

Signed-off-by: Felipe Contreras 
---
 Makefile | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 3588ca1..e51b92e 100644
--- a/Makefile
+++ b/Makefile
@@ -511,12 +511,14 @@ build-perl-script: $(SCRIPT_PERL_GEN)
 build-sh-script: $(SCRIPT_SH_GEN)
 build-python-script: $(SCRIPT_PYTHON_GEN)
 
-.PHONY: install-perl-script install-sh-script install-python-script
-install-sh-script: $(SCRIPT_SH_INS)
+.PHONY: install-gitexecdir install-perl-script install-sh-script 
install-python-script
+install-gitexecdir:
+   $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
+install-sh-script: $(SCRIPT_SH_INS) | install-gitexecdir
$(INSTALL) $^ '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
-install-perl-script: $(SCRIPT_PERL_INS)
+install-perl-script: $(SCRIPT_PERL_INS) | install-gitexecdir
$(INSTALL) $^ '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
-install-python-script: $(SCRIPT_PYTHON_INS)
+install-python-script: $(SCRIPT_PYTHON_INS) | install-gitexecdir
$(INSTALL) $^ '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
 
 .PHONY: clean-perl-script clean-sh-script clean-python-script
-- 
1.8.4-fc

--
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 try2 14/14] completion: update 'git reset' new stage options

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 contrib/completion/git-completion.bash | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/contrib/completion/git-completion.bash 
b/contrib/completion/git-completion.bash
index 1dde51f..082f207 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2231,7 +2231,8 @@ _git_reset ()
 
case "$cur" in
--*)
-   __gitcomp "--merge --mixed --hard --soft --patch"
+   __gitcomp "--merge --mixed --hard --soft --patch --keep --merge
+   --stage --no-stage --work --no-work"
return
;;
esac
-- 
1.8.4-fc

--
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 v2 4/5] remote-helpers: allow direct test execution

2013-10-12 Thread Felipe Contreras
Previously 'make' was the only option, or manually specifying the
'TEST_DIRECTORY'.

Signed-off-by: Felipe Contreras 
---
 contrib/remote-helpers/Makefile | 1 +
 contrib/remote-helpers/test-bzr.t   | 3 ++-
 contrib/remote-helpers/test-hg-bidi.t   | 3 ++-
 contrib/remote-helpers/test-hg-hg-git.t | 3 ++-
 contrib/remote-helpers/test-hg.t| 3 ++-
 5 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/contrib/remote-helpers/Makefile b/contrib/remote-helpers/Makefile
index 8d5e9be..8799c77 100644
--- a/contrib/remote-helpers/Makefile
+++ b/contrib/remote-helpers/Makefile
@@ -5,6 +5,7 @@ export T := $(addprefix $(CURDIR)/,$(TESTS))
 export MAKE := $(MAKE) -e
 export PATH := $(CURDIR):$(PATH)
 export TEST_LINT := test-lint-executable test-lint-shell-syntax
+export TEST_DIRECTORY := $(CURDIR)/../../t
 
 export SCRIPT_PYTHON := $(addprefix $(CURDIR)/,$(SCRIPTS))
 
diff --git a/contrib/remote-helpers/test-bzr.t 
b/contrib/remote-helpers/test-bzr.t
index 435b280..7ca4a9c 100755
--- a/contrib/remote-helpers/test-bzr.t
+++ b/contrib/remote-helpers/test-bzr.t
@@ -5,7 +5,8 @@
 
 test_description='Test remote-bzr'
 
-. ./test-lib.sh
+test -z "$TEST_DIRECTORY" && TEST_DIRECTORY="$PWD/../../t"
+. "$TEST_DIRECTORY"/test-lib.sh
 
 if ! test_have_prereq PYTHON; then
skip_all='skipping remote-bzr tests; python not available'
diff --git a/contrib/remote-helpers/test-hg-bidi.t 
b/contrib/remote-helpers/test-hg-bidi.t
index 86a3f10..e978932 100755
--- a/contrib/remote-helpers/test-hg-bidi.t
+++ b/contrib/remote-helpers/test-hg-bidi.t
@@ -8,7 +8,8 @@
 
 test_description='Test bidirectionality of remote-hg'
 
-. ./test-lib.sh
+test -z "$TEST_DIRECTORY" && TEST_DIRECTORY="$PWD/../../t"
+. "$TEST_DIRECTORY"/test-lib.sh
 
 if ! test_have_prereq PYTHON; then
skip_all='skipping remote-hg tests; python not available'
diff --git a/contrib/remote-helpers/test-hg-hg-git.t 
b/contrib/remote-helpers/test-hg-hg-git.t
index 0217860..0caa493 100755
--- a/contrib/remote-helpers/test-hg-hg-git.t
+++ b/contrib/remote-helpers/test-hg-hg-git.t
@@ -8,7 +8,8 @@
 
 test_description='Test remote-hg output compared to hg-git'
 
-. ./test-lib.sh
+test -z "$TEST_DIRECTORY" && TEST_DIRECTORY="$PWD/../../t"
+. "$TEST_DIRECTORY"/test-lib.sh
 
 if ! test_have_prereq PYTHON; then
skip_all='skipping remote-hg tests; python not available'
diff --git a/contrib/remote-helpers/test-hg.t b/contrib/remote-helpers/test-hg.t
index 30f4ff6..9b6dd95 100755
--- a/contrib/remote-helpers/test-hg.t
+++ b/contrib/remote-helpers/test-hg.t
@@ -8,7 +8,8 @@
 
 test_description='Test remote-hg'
 
-. ./test-lib.sh
+test -z "$TEST_DIRECTORY" && TEST_DIRECTORY="$PWD/../../t"
+. "$TEST_DIRECTORY"/test-lib.sh
 
 if ! test_have_prereq PYTHON; then
skip_all='skipping remote-hg tests; python not available'
-- 
1.8.4-fc

--
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 v2 5/5] remote-helpers: add exec-path links

2013-10-12 Thread Felipe Contreras
This way we don't have to modify the PATH ourselves and it's easier to
test without 'make'.

Signed-off-by: Felipe Contreras 
---
 contrib/remote-helpers/Makefile | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/contrib/remote-helpers/Makefile b/contrib/remote-helpers/Makefile
index 8799c77..2e14b65 100644
--- a/contrib/remote-helpers/Makefile
+++ b/contrib/remote-helpers/Makefile
@@ -1,15 +1,15 @@
 TESTS := $(wildcard test-*.t)
 SCRIPTS := $(wildcard git-remote-*.py)
+LINKS := $(addprefix ../../,$(patsubst %.py,%,$(SCRIPTS)))
 
 export T := $(addprefix $(CURDIR)/,$(TESTS))
 export MAKE := $(MAKE) -e
-export PATH := $(CURDIR):$(PATH)
 export TEST_LINT := test-lint-executable test-lint-shell-syntax
 export TEST_DIRECTORY := $(CURDIR)/../../t
 
 export SCRIPT_PYTHON := $(addprefix $(CURDIR)/,$(SCRIPTS))
 
-all: $(SCRIPTS)
+all: $(LINKS)
$(MAKE) -C ../.. build-python-script
 
 install:
@@ -17,10 +17,14 @@ install:
 
 clean:
$(MAKE) -C ../.. clean-python-script
+   $(RM) $(LINKS)
 
 test: all
$(MAKE) -C ../../t $@
 
+$(LINKS):
+   ln -sf contrib/remote-helpers/$(notdir $@) ../..
+
 $(TESTS): all
$(MAKE) -C ../../t $(CURDIR)/$@
 
-- 
1.8.4-fc

--
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 v3] Add core.mode configuration

2013-10-12 Thread Felipe Contreras
So that we can specify general modes of operation, specifically, add the
'next' mode, which makes Git pre v2.0 behave as Git v2.0.

Signed-off-by: Felipe Contreras 
---
 builtin/add.c  | 13 
 cache.h|  6 ++
 config.c   | 13 
 environment.c  |  1 +
 t/t2205-add-new.sh | 60 ++
 5 files changed, 89 insertions(+), 4 deletions(-)
 create mode 100755 t/t2205-add-new.sh

diff --git a/builtin/add.c b/builtin/add.c
index 8266a9c..95a396d 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -483,14 +483,16 @@ int cmd_add(int argc, const char **argv, const char 
*prefix)
 */
memset(&update_data, 0, sizeof(update_data));
if (!take_worktree_changes && addremove_explicit < 0)
-   update_data.warn_add_would_remove = 1;
+   if (git_mode == MODE_CURRENT)
+   update_data.warn_add_would_remove = 1;
 
if (!take_worktree_changes && addremove_explicit < 0 && argc)
/*
 * Turn "git add pathspec..." to "git add -A pathspec..."
 * in Git 2.0 but not yet
 */
-   ; /* addremove = 1; */
+   if (git_mode != MODE_CURRENT)
+   addremove = 1;
 
if (!show_only && ignore_missing)
die(_("Option --ignore-missing can only be used together with 
--dry-run"));
@@ -503,10 +505,13 @@ int cmd_add(int argc, const char **argv, const char 
*prefix)
short_option_with_implicit_dot = "-u";
}
if (option_with_implicit_dot && !argc) {
-   static const char *here[2] = { ".", NULL };
+   static const char *here[2] = { ":/", NULL };
argc = 1;
argv = here;
-   implicit_dot = 1;
+   if (git_mode == MODE_CURRENT) {
+   here[0] = ".";
+   implicit_dot = 1;
+   }
}
 
add_new_files = !take_worktree_changes && !refresh_only;
diff --git a/cache.h b/cache.h
index 85b544f..f28240f 100644
--- a/cache.h
+++ b/cache.h
@@ -627,9 +627,15 @@ enum push_default_type {
PUSH_DEFAULT_UNSPECIFIED
 };
 
+enum git_mode {
+   MODE_CURRENT = 0,
+   MODE_NEXT
+};
+
 extern enum branch_track git_branch_track;
 extern enum rebase_setup_type autorebase;
 extern enum push_default_type push_default;
+extern enum git_mode git_mode;
 
 enum object_creation_mode {
OBJECT_CREATION_USES_HARDLINKS = 0,
diff --git a/config.c b/config.c
index e13a7b6..f0e0370 100644
--- a/config.c
+++ b/config.c
@@ -831,6 +831,19 @@ static int git_default_core_config(const char *var, const 
char *value)
return 0;
}
 
+   if (!strcmp(var, "core.mode")) {
+   if (!value)
+   return config_error_nonbool(var);
+   else if (!strcmp(value, "current"))
+   git_mode = MODE_CURRENT;
+   else if (!strcmp(value, "next")) {
+   git_mode = MODE_NEXT;
+   push_default = PUSH_DEFAULT_SIMPLE;
+   } else
+   die("wrong mode '%s'", value);
+   return 0;
+   }
+
/* Add other config variables here and to Documentation/config.txt. */
return 0;
 }
diff --git a/environment.c b/environment.c
index 5398c36..751e14d 100644
--- a/environment.c
+++ b/environment.c
@@ -62,6 +62,7 @@ int merge_log_config = -1;
 int precomposed_unicode = -1; /* see probe_utf8_pathname_composition() */
 struct startup_info *startup_info;
 unsigned long pack_size_limit_cfg;
+enum git_mode git_mode = MODE_CURRENT;
 
 /*
  * The character that begins a commented line in user-editable file
diff --git a/t/t2205-add-new.sh b/t/t2205-add-new.sh
new file mode 100755
index 000..763664b
--- /dev/null
+++ b/t/t2205-add-new.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+test_description='git add v2.0 behavior'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+   mkdir dir1 &&
+   echo one > dir1/content &&
+   echo one > dir1/to-remove &&
+   git add . &&
+   git commit -m one
+'
+
+test_expect_success 'update in dir throws warning' '
+   test_when_finished "git reset --hard" &&
+   echo two > dir1/content &&
+   mkdir -p dir2 &&
+   (
+   cd dir2 &&
+   git add -u 2> err &&
+   cat err &&
+   grep "will change in Git 2.0" err
+   )
+'
+
+test_expect_success 'update in dir updates everything' '
+   test_when_finished "git reset --hard" &&
+   test_config core.mode next &&
+   echo two > dir1/content &&
+   mkdir -p dir2 &&
+   (
+   cd dir2 &&
+   git add -u 2> err &&
+   cat err &&
+   ! grep "will change in Git 2.0" err
+   ) &&
+   test "$(git ls-files -m)" = ""
+'
+
+test_expect_success 'default to ignore removal' '
+   test_when_finished "git reset --hard" &&
+ 

[PATCH v3 02/10] transport-helper: fix extra lines

2013-10-12 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 
Signed-off-by: Felipe Contreras 
---
 transport-helper.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/transport-helper.c b/transport-helper.c
index cd913af..ed3384e 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -840,9 +840,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-fc

--
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 try2 00/14] Officially start moving to the term 'staging area'

2013-10-12 Thread Felipe Contreras
tl;dr: everyone except Junio C Hamano and Drew Northup agrees; we should move
away from the name "the index".

It has been discussed many times in the past that 'index' is not an
appropriate description for what the high-level user does with it, and
it has been agreed that 'staging area' is the best term.

The term 'staging area' is more intuitive for newcomers which are more
familiar with English than with Git, and it seems to be a
straightforward mental notion for people with different mother tongues.

In fact it is so intuitive that it's used already in a lot online
documentation, and the people that do teach Git professionally use this
term, because it's easier for many kinds of audiences to grasp.

The meaning of the words 'cache' and 'index' doesn't represent correctly
the mental model of the high-level user:

cache: a 'cache' is a place for easier access; a squirrel caches nuts
so it doesn't have to go looking for them in the future when it might
be much more difficult. Git porcelain is not using the staging area
for easier future access; it's not a cache.

index: an 'index' is a guide of pointers to something else; a book
index has a list of entries so the reader can locate information
easily without having to go through the whole book. Git porcelain is
not using the staging area to find out entries quicker; it's not an
index.

stage: a 'stage' is a special area designated for convenience in order
for some activity to take place; an orator would prepare a stage in
order for her speak to be successful, otherwise many people might not
be able to hear, or see her. Git porcelain is using the staging area
precisely as a special area to be separated from the working directory
for convenience.

The term 'stage' is a good noun itself, but also 'staging area', it
has a good verb; 'to stage', and a nice past-participle; 'staged'.

The first step in moving Git towards this term, is first to add --stage
options for every command that uses --index or --cache. However, there's
a problem with the 'git apply' command, because it treats --index and
--cache differently. Different solutions were proposed, including a
special --stage-only option, however, I think the best solution is a
--[no-]work option to specify if the working directory should be touched
or not, so --index becomes --staged, and --cached becomes --staged
--no-work.

In addition, the 'git stage' command can be extended so the staging area
can be brought closer to the user, like other important Git concepts,
like 'git branch, 'git tag', and 'git remote'. For example, the command
'git stage edit' (which allows the user to edit directly the diff from
HEAD to the staging area) can have a home, where previously there was no
place. It would become natural then to do 'git stage diff', and then
'git stage edit' (to edit the previous diff).

After adding the new --stage options and making sure no functionality is
lost, they can become the recommended ones in the documentation,
eventually, the old ones get deprecated, and eventually obsoleted.

Also, the documentation would need to be updated to replace many
instances of 'the index', with 'the staging area' in porcelain commands.

Moreover, the --stage and --work options also make sense for 'git
reset', and after these options are added, the complicated table to
explain the different behaviors between --soft, --mixed, and --hard
becomes so simple it's not needed any more:

  working stage HEAD target working stage HEAD
  
   A   B CD --no-stage  A   B D
--stage A   D D
--work  D   D D

  working stage HEAD target working stage HEAD
  
   A   B CC --no-stage  A   B C
--stage A   C C
--work  C   C C

  working stage HEAD target working stage HEAD
  
   B   B CD --no-stage  B   B D
--stage B   D D
--work  D   D D

  working stage HEAD target working stage HEAD
  
   B   B CC --no-stage  B   B C
--stage B   C C
--work  C   C C

  working stage HEAD target working stage HEAD
  
   B   C CD --no-stage  B   C D
--stage B   D D
--work  D   D D

  working stage HEAD target working 

[PATCH try2 06/14] stash: add --stage option to save

2013-10-12 Thread Felipe Contreras
--no-stage is synonym for --keep-index.

Signed-off-by: Felipe Contreras 
---
 Documentation/git-stash.txt | 6 +++---
 git-stash.sh| 8 +++-
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt
index db7e803..75b4cc6 100644
--- a/Documentation/git-stash.txt
+++ b/Documentation/git-stash.txt
@@ -13,7 +13,7 @@ SYNOPSIS
 'git stash' drop [-q|--quiet] []
 'git stash' ( pop | apply ) [--index] [-q|--quiet] []
 'git stash' branch  []
-'git stash' [save [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]
+'git stash' [save [-p|--patch] [-k|--[no-]keep-index|--[no-]stage] [-q|--quiet]
 [-u|--include-untracked] [-a|--all] []]
 'git stash' clear
 'git stash' create []
@@ -44,7 +44,7 @@ is also possible).
 OPTIONS
 ---
 
-save [-p|--patch] [--[no-]keep-index] [-u|--include-untracked] [-a|--all] 
[-q|--quiet] []::
+save [-p|--patch] [--[no-]keep-index|--[no-]stage] [-u|--include-untracked] 
[-a|--all] [-q|--quiet] []::
 
Save your local modifications to a new 'stash', and run `git reset
--hard` to revert them.  The  part is optional and gives
@@ -54,7 +54,7 @@ save [-p|--patch] [--[no-]keep-index] 
[-u|--include-untracked] [-a|--all] [-q|--
subcommand from making an unwanted stash.
 +
 If the `--keep-index` option is used, all changes already added to the
-index are left intact.
+index are left intact. Same with `--no-stage`, which is a snynonym.
 +
 If the `--include-untracked` option is used, all untracked files are also
 stashed and then cleaned up with `git clean`, leaving the working directory
diff --git a/git-stash.sh b/git-stash.sh
index 1e541a2..47220d0 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -7,7 +7,7 @@ USAGE="list []
or: $dashless drop [-q|--quiet] []
or: $dashless ( pop | apply ) [--index] [-q|--quiet] []
or: $dashless branch  []
-   or: $dashless [save [--patch] [-k|--[no-]keep-index] [-q|--quiet]
+   or: $dashless [save [--patch] [-k|--[no-]keep-index|--[no-]stage] 
[-q|--quiet]
   [-u|--include-untracked] [-a|--all] []]
or: $dashless clear"
 
@@ -204,6 +204,12 @@ save_stash () {
--no-keep-index)
keep_index=n
;;
+   --stage)
+   keep_index=n
+   ;;
+   --no-stage)
+   keep_index=t
+   ;;
-p|--patch)
patch_mode=t
# only default to keep if we don't already have an 
override
-- 
1.8.4-fc

--
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 v3 01/10] transport-helper: add 'force' to 'export' helpers

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

Signed-off-by: Felipe Contreras 
---
 transport-helper.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/transport-helper.c b/transport-helper.c
index 63cabc3..cd913af 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -814,6 +814,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-fc

--
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 v3 08/10] fast-export: add support to delete refs

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 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 7f314f0..9b728ca 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -665,6 +665,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;
@@ -755,6 +768,7 @@ int cmd_fast_export(int argc, const char **argv, const char 
*prefix)
}
 
handle_tags_and_duplicates(&extra_refs);
+   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-fc

--
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 v3 10/10] transport-helper: don't update refs in dry-run

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

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

diff --git a/transport-helper.c b/transport-helper.c
index ddb3309..d94eaf4 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -715,7 +715,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;
@@ -729,7 +730,7 @@ static void push_update_refs_status(struct helper_data 
*data,
if (push_update_ref_status(&buf, &ref, remote_refs))
continue;
 
-   if (!data->refspecs)
+   if (flags & TRANSPORT_PUSH_DRY_RUN || !data->refspecs)
continue;
 
/* propagate back the update to the remote namespace */
@@ -799,7 +800,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;
 }
 
@@ -869,7 +870,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-fc

--
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 try2 05/14] rm: add --staged option

2013-10-12 Thread Felipe Contreras
Synonym for --cached.

Signed-off-by: Felipe Contreras 
---
 Documentation/git-rm.txt | 5 -
 builtin/rm.c | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/Documentation/git-rm.txt b/Documentation/git-rm.txt
index 1d876c2..156b40d 100644
--- a/Documentation/git-rm.txt
+++ b/Documentation/git-rm.txt
@@ -8,7 +8,7 @@ git-rm - Remove files from the working tree and from the index
 SYNOPSIS
 
 [verse]
-'git rm' [-f | --force] [-n] [-r] [--cached] [--ignore-unmatch] [--quiet] [--] 
...
+'git rm' [-f | --force] [-n] [-r] [--cached | --staged] [--ignore-unmatch] 
[--quiet] [--] ...
 
 DESCRIPTION
 ---
@@ -60,6 +60,9 @@ OPTIONS
Working tree files, whether modified or not, will be
left alone.
 
+--staged::
+   Synonym for --cached.
+
 --ignore-unmatch::
Exit with a zero status even if no files matched.
 
diff --git a/builtin/rm.c b/builtin/rm.c
index 0df0b4d..919911f 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -268,6 +268,7 @@ static struct option builtin_rm_options[] = {
OPT__DRY_RUN(&show_only, N_("dry run")),
OPT__QUIET(&quiet, N_("do not list removed files")),
OPT_BOOLEAN( 0 , "cached", &index_only, N_("only remove from 
the index")),
+   OPT_BOOLEAN( 0 , "staged", &index_only, N_("only remove from 
the index")),
OPT__FORCE(&force, N_("override the up-to-date check")),
OPT_BOOLEAN('r', NULL, &recursive,  N_("allow recursive 
removal")),
OPT_BOOLEAN( 0 , "ignore-unmatch", &ignore_unmatch,
-- 
1.8.4-fc

--
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 try2 02/14] stage: add edit command

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 Documentation/git-stage.txt|  5 +++
 builtin/stage.c| 74 ++
 contrib/completion/git-completion.bash |  4 +-
 3 files changed, 82 insertions(+), 1 deletion(-)

diff --git a/Documentation/git-stage.txt b/Documentation/git-stage.txt
index 318bf45..3e52a66 100644
--- a/Documentation/git-stage.txt
+++ b/Documentation/git-stage.txt
@@ -15,6 +15,7 @@ SYNOPSIS
 'git stage diff' [options] [] [--] [...]
 'git stage rm' [options] [--] [...]
 'git stage apply' [options] [--] [...]
+'git stage edit'
 
 DESCRIPTION
 ---
@@ -45,6 +46,10 @@ Remove files from the staging area only. See 
linkgit:git-rm[1] --staged.
 
 Apply a patch to the staging area. See linkgit:git-rm[1] --staged.
 
+'edit'::
+
+Manually edit the staging area (as a diff).
+
 SEE ALSO
 
 linkgit:git-add[1]
diff --git a/builtin/stage.c b/builtin/stage.c
index 3023d17..d3c58d5 100644
--- a/builtin/stage.c
+++ b/builtin/stage.c
@@ -6,6 +6,9 @@
 
 #include "builtin.h"
 #include "parse-options.h"
+#include "diff.h"
+#include "diffcore.h"
+#include "revision.h"
 
 static const char *const stage_usage[] = {
N_("git stage [options] [--] ..."),
@@ -16,6 +19,74 @@ static const char *const stage_usage[] = {
NULL
 };
 
+static int do_reset(const char *prefix)
+{
+   const char *argv[] = { "reset", "--quiet", NULL };
+   return cmd_reset(2, argv, prefix);
+}
+
+static int do_apply(const char *file, const char *prefix)
+{
+   const char *argv[] = { "apply", "--recount", "--cached", file, NULL };
+   return cmd_apply(4, argv, prefix);
+}
+
+static int edit(int argc, const char **argv, const char *prefix)
+{
+   char *file = git_pathdup("STAGE_EDIT.patch");
+   int out;
+   struct rev_info rev;
+   int ret = 0;
+   struct stat st;
+
+   read_cache();
+
+   init_revisions(&rev, prefix);
+   rev.diffopt.context = 7;
+
+   argc = setup_revisions(argc, argv, &rev, NULL);
+   add_head_to_pending(&rev);
+   if (!rev.pending.nr) {
+   struct tree *tree;
+   tree = lookup_tree(EMPTY_TREE_SHA1_BIN);
+   add_pending_object(&rev, &tree->object, "HEAD");
+   }
+
+   rev.diffopt.output_format = DIFF_FORMAT_PATCH;
+   rev.diffopt.use_color = 0;
+   DIFF_OPT_SET(&rev.diffopt, IGNORE_DIRTY_SUBMODULES);
+
+   out = open(file, O_CREAT | O_WRONLY, 0666);
+   if (out < 0)
+   die(_("Could not open '%s' for writing."), file);
+   rev.diffopt.file = xfdopen(out, "w");
+   rev.diffopt.close_file = 1;
+
+   if (run_diff_index(&rev, 1))
+   die(_("Could not write patch"));
+   if (launch_editor(file, NULL, NULL))
+   exit(1);
+
+   if (stat(file, &st))
+   die_errno(_("Could not stat '%s'"), file);
+
+   ret = do_reset(prefix);
+   if (ret)
+   goto leave;
+
+   if (!st.st_size)
+   goto leave;
+
+   ret = do_apply(file, prefix);
+   if (ret)
+   goto leave;
+
+leave:
+   unlink(file);
+   free(file);
+   return ret;
+}
+
 int cmd_stage(int argc, const char **argv, const char *prefix)
 {
struct option options[] = { OPT_END() };
@@ -46,6 +117,9 @@ int cmd_stage(int argc, const char **argv, const char 
*prefix)
 
return cmd_apply(argc, argv, prefix);
}
+   if (!strcmp(argv[1], "edit")) {
+   return edit(argc - 1, argv + 1, prefix);
+   }
}
 
return cmd_add(argc, argv, prefix);
diff --git a/contrib/completion/git-completion.bash 
b/contrib/completion/git-completion.bash
index 8cf26e2..2b81e78 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1693,7 +1693,7 @@ _git_stage ()
 {
__git_has_doubledash && return
 
-   local subcommands="add reset diff rm apply"
+   local subcommands="add reset diff rm apply edit"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
__gitcomp "$subcommands"
@@ -1711,6 +1711,8 @@ _git_stage ()
_git_rm;;
apply)
_git_apply;;
+   edit)
+   ;;
*)
_git_add;
esac
-- 
1.8.4-fc

--
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 try2 11/14] completion: update --staged options

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 contrib/completion/git-completion.bash | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/contrib/completion/git-completion.bash 
b/contrib/completion/git-completion.bash
index 2b81e78..1dde51f 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -881,7 +881,7 @@ _git_apply ()
__gitcomp "
--stat --numstat --summary --check --index
--cached --index-info --reverse --reject --unidiff-zero
-   --apply --no-add --exclude=
+   --apply --no-add --exclude= --staged
--ignore-whitespace --ignore-space-change
--whitespace= --inaccurate-eof --verbose
"
@@ -1294,7 +1294,7 @@ _git_grep ()
case "$cur" in
--*)
__gitcomp "
-   --cached
+   --cached --staged
--text --ignore-case --word-regexp --invert-match
--full-name --line-number
--extended-regexp --basic-regexp --fixed-strings
@@ -2253,7 +2253,7 @@ _git_rm ()
 {
case "$cur" in
--*)
-   __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
+   __gitcomp "--cached --staged --dry-run --ignore-unmatch --quiet"
return
;;
esac
@@ -2320,7 +2320,7 @@ _git_show_branch ()
 
 _git_stash ()
 {
-   local save_opts='--keep-index --no-keep-index --quiet --patch'
+   local save_opts='--keep-index --no-keep-index --stage --no-stage 
--quiet --patch'
local subcommands='save list show apply clear drop pop create branch'
local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
@@ -2340,7 +2340,7 @@ _git_stash ()
__gitcomp "$save_opts"
;;
apply,--*|pop,--*)
-   __gitcomp "--index --quiet"
+   __gitcomp "--index --stage --quiet"
;;
show,--*|drop,--*|branch,--*)
;;
-- 
1.8.4-fc

--
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 try2 07/14] stash: add --stage to pop and apply

2013-10-12 Thread Felipe Contreras
Synonym of --index.

Signed-off-by: Felipe Contreras 
---
 Documentation/git-stash.txt | 8 
 git-stash.sh| 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt
index 75b4cc6..b4066fd 100644
--- a/Documentation/git-stash.txt
+++ b/Documentation/git-stash.txt
@@ -11,7 +11,7 @@ SYNOPSIS
 'git stash' list []
 'git stash' show []
 'git stash' drop [-q|--quiet] []
-'git stash' ( pop | apply ) [--index] [-q|--quiet] []
+'git stash' ( pop | apply ) [--index|--stage] [-q|--quiet] []
 'git stash' branch  []
 'git stash' [save [-p|--patch] [-k|--[no-]keep-index|--[no-]stage] [-q|--quiet]
 [-u|--include-untracked] [-a|--all] []]
@@ -96,7 +96,7 @@ show []::
it will accept any format known to 'git diff' (e.g., `git stash show
-p stash@{1}` to view the second most recent stash in patch form).
 
-pop [--index] [-q|--quiet] []::
+pop [--index|--stage] [-q|--quiet] []::
 
Remove a single stashed state from the stash list and apply it
on top of the current working tree state, i.e., do the inverse
@@ -110,12 +110,12 @@ and call `git stash drop` manually afterwards.
 If the `--index` option is used, then tries to reinstate not only the working
 tree's changes, but also the index's ones. However, this can fail, when you
 have conflicts (which are stored in the index, where you therefore can no
-longer apply the changes as they were originally).
+longer apply the changes as they were originally). `--stage` is a synonym.
 +
 When no `` is given, `stash@{0}` is assumed, otherwise `` must
 be a reference of the form `stash@{}`.
 
-apply [--index] [-q|--quiet] []::
+apply [--index|--stage] [-q|--quiet] []::
 
Like `pop`, but do not remove the state from the stash list. Unlike 
`pop`,
`` may be any commit that looks like a commit created by
diff --git a/git-stash.sh b/git-stash.sh
index 47220d0..e2eb8dc 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -5,7 +5,7 @@ dashless=$(basename "$0" | sed -e 's/-/ /')
 USAGE="list []
or: $dashless show []
or: $dashless drop [-q|--quiet] []
-   or: $dashless ( pop | apply ) [--index] [-q|--quiet] []
+   or: $dashless ( pop | apply ) [--index|--stage] [-q|--quiet] []
or: $dashless branch  []
or: $dashless [save [--patch] [-k|--[no-]keep-index|--[no-]stage] 
[-q|--quiet]
   [-u|--include-untracked] [-a|--all] []]
@@ -373,7 +373,7 @@ parse_flags_and_rev()
-q|--quiet)
GIT_QUIET=-t
;;
-   --index)
+   --index|--stage)
INDEX_OPTION=--index
;;
-*)
-- 
1.8.4-fc

--
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 v3 00/10] transport-helper: updates

2013-10-12 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 v2:

--- a/transport-helper.c
+++ b/transport-helper.c
@@ -821,8 +821,10 @@ static int push_refs_with_export(struct transport 
*transport,
die("helper %s does not support dry-run", data->name);
}
 
-   if (flags & TRANSPORT_PUSH_FORCE)
-   set_helper_option(transport, "force", "true");
+   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);
 

Felipe Contreras (10):
  transport-helper: add 'force' to 'export' helpers
  transport-helper: fix extra lines
  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
  transport-helper: don't update refs in dry-run

 Documentation/git-fast-export.txt |  4 
 Documentation/git-fast-import.txt |  3 +++
 builtin/fast-export.c | 47 ++-
 fast-import.c | 13 ---
 t/t5801-remote-helpers.sh | 10 -
 t/t9300-fast-import.sh| 18 +++
 t/t9350-fast-export.sh| 18 +++
 transport-helper.c| 44 ++--
 8 files changed, 140 insertions(+), 17 deletions(-)

-- 
1.8.4-fc

--
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 try2 13/14] reset: allow --keep with --stage

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 Documentation/git-reset.txt |  2 +-
 builtin/reset.c | 13 ++---
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
index 5cd75a8..a1419c9 100644
--- a/Documentation/git-reset.txt
+++ b/Documentation/git-reset.txt
@@ -11,7 +11,7 @@ SYNOPSIS
 'git reset' [-q] [] [--] ...
 'git reset' (--patch | -p) [] [--] [...]
 'git reset' [--soft | --mixed | --hard | --merge | --keep] [-q] []
-'git reset' [--stage | --work] [-q] []
+'git reset' [--stage | --work | --keep] [-q] []
 
 DESCRIPTION
 ---
diff --git a/builtin/reset.c b/builtin/reset.c
index fbc1abc..dde03a7 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -23,7 +23,7 @@
 
 static const char * const git_reset_usage[] = {
N_("git reset [--mixed | --soft | --hard | --merge | --keep] [-q] 
[]"),
-   N_("git reset [--stage | --work] [-q] []"),
+   N_("git reset [--stage | --work | --keep] [-q] []"),
N_("git reset [-q]  [--] ..."),
N_("git reset --patch [] [--] [...]"),
NULL
@@ -295,8 +295,15 @@ int cmd_reset(int argc, const char **argv, const char 
*prefix)
}
 
if (stage >= 0 || working_tree >= 0) {
-   if (reset_type != NONE)
+   int keep = 0;
+
+   if (reset_type == KEEP) {
+   if (working_tree == 1)
+   die(_("--keep is incompatible with --work"));
+   keep = 1;
+   } else if (reset_type != NONE) {
die(_("--{stage,work} are incompatible with 
--{hard,mixed,soft,merge}"));
+   }
 
if (working_tree == 1) {
if (stage == 0)
@@ -304,7 +311,7 @@ int cmd_reset(int argc, const char **argv, const char 
*prefix)
reset_type = HARD;
} else {
if (stage == 1)
-   reset_type = NONE;
+   reset_type = keep ? KEEP : NONE;
else
reset_type = SOFT;
}
-- 
1.8.4-fc

--
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 v3 09/10] transport-helper: add support to delete branches

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

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

diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index 8e2dd9f..a66a4e3 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 'cloning without refspec' '
GIT_REMOTE_TESTGIT_REFSPEC="" \
git clone "testgit::${PWD}/server" local2 2>error &&
diff --git a/transport-helper.c b/transport-helper.c
index cffeb9a..ddb3309 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -849,12 +849,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-fc

--
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 v3 05/10] fast-export: add new --refspec option

2013-10-12 Thread Felipe Contreras
So that we can covert the exported ref names.

Signed-off-by: Felipe Contreras 
---
 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.
+
 [...]::
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 91114f4..7f314f0 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]"),
@@ -30,6 +31,8 @@ static int fake_missing_tagger;
 static int use_done_feature;
 static int no_data;
 static int full_tree;
+static struct refspec *refspecs;
+static int refspecs_nr;
 
 static int parse_opt_signed_tag_mode(const struct option *opt,
 const char *arg, int unset)
@@ -502,6 +505,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;
+   }
+   }
+
switch (e->item->type) {
case OBJ_COMMIT:
commit = (struct commit *)e->item;
@@ -661,6 +673,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;
struct option options[] = {
OPT_INTEGER(0, "progress", &progress,
N_("show progress after  objects")),
@@ -681,6 +694,8 @@ int cmd_fast_export(int argc, const char **argv, const char 
*prefix)
OPT_BOOLEAN(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()
};
 
@@ -700,6 +715,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");
 
@@ -734,5 +762,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-fc

--
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 try2 08/14] submodule: add --staged options

2013-10-12 Thread Felipe Contreras
Synonym for --cached.

Signed-off-by: Felipe Contreras 
---
 Documentation/git-submodule.txt |  8 ++--
 git-submodule.sh| 10 +-
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
index bfef8a0..904e007 100644
--- a/Documentation/git-submodule.txt
+++ b/Documentation/git-submodule.txt
@@ -11,13 +11,13 @@ SYNOPSIS
 [verse]
 'git submodule' [--quiet] add [-b ] [-f|--force] [--name ]
  [--reference ] [--depth ] [--]  
[]
-'git submodule' [--quiet] status [--cached] [--recursive] [--] [...]
+'git submodule' [--quiet] status [--cached|--staged] [--recursive] [--] 
[...]
 'git submodule' [--quiet] init [--] [...]
 'git submodule' [--quiet] deinit [-f|--force] [--] ...
 'git submodule' [--quiet] update [--init] [--remote] [-N|--no-fetch]
  [-f|--force] [--rebase] [--reference ] [--depth 
]
  [--merge] [--recursive] [--] [...]
-'git submodule' [--quiet] summary [--cached|--files] [(-n|--summary-limit) ]
+'git submodule' [--quiet] summary [--cached|--staged|--files] 
[(-n|--summary-limit) ]
  [commit] [--] [...]
 'git submodule' [--quiet] foreach [--recursive] 
 'git submodule' [--quiet] sync [--] [...]
@@ -248,6 +248,10 @@ OPTIONS
commands typically use the commit found in the submodule HEAD, but
with this option, the commit stored in the index is used instead.
 
+
+--staged::
+   Synonym for `--cached`.
+
 --files::
This option is only valid for the summary command. This command
compares the commit in the index with that in the submodule HEAD
diff --git a/git-submodule.sh b/git-submodule.sh
index 2979197..823b783 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -6,11 +6,11 @@
 
 dashless=$(basename "$0" | sed -e 's/-/ /')
 USAGE="[--quiet] add [-b ] [-f|--force] [--name ] [--reference 
] [--]  []
-   or: $dashless [--quiet] status [--cached] [--recursive] [--] [...]
+   or: $dashless [--quiet] status [--cached|--staged] [--recursive] [--] 
[...]
or: $dashless [--quiet] init [--] [...]
or: $dashless [--quiet] deinit [-f|--force] [--] ...
or: $dashless [--quiet] update [--init] [--remote] [-N|--no-fetch] 
[-f|--force] [--rebase] [--reference ] [--merge] [--recursive] [--] 
[...]
-   or: $dashless [--quiet] summary [--cached|--files] [--summary-limit ] 
[commit] [--] [...]
+   or: $dashless [--quiet] summary [--cached|--staged|--files] 
[--summary-limit ] [commit] [--] [...]
or: $dashless [--quiet] foreach [--recursive] 
or: $dashless [--quiet] sync [--recursive] [--] [...]"
 OPTIONS_SPEC=
@@ -972,7 +972,7 @@ cmd_summary() {
while test $# -ne 0
do
case "$1" in
-   --cached)
+   --cached|--staged)
cached="$1"
;;
--files)
@@ -1181,7 +1181,7 @@ cmd_status()
-q|--quiet)
GIT_QUIET=1
;;
-   --cached)
+   --cached|--staged)
cached=1
;;
--recursive)
@@ -1348,7 +1348,7 @@ do
esac
branch="$2"; shift
;;
-   --cached)
+   --cached|--staged)
cached="$1"
;;
--)
-- 
1.8.4-fc

--
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 v3 07/10] fast-import: add support to delete refs

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 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 bf1a02a..fe5c952 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 23f625f..b6be7a7 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];
 };
@@ -1674,10 +1675,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);
if (!lock)
return error("Unable to lock %s", b->name);
@@ -2604,8 +2608,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 ac6f3b6..0150aa6 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -2934,4 +2934,22 @@ test_expect_success 'S: ls with garbage after sha1 must 
fail' '
test_i18ngrep "space after tree-ish" err
 '
 
+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-fc

--
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 try2 12/14] reset: add --stage and --work options

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 Documentation/git-reset.txt |  8 
 builtin/reset.c | 20 
 2 files changed, 28 insertions(+)

diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
index f445cb3..5cd75a8 100644
--- a/Documentation/git-reset.txt
+++ b/Documentation/git-reset.txt
@@ -11,6 +11,7 @@ SYNOPSIS
 'git reset' [-q] [] [--] ...
 'git reset' (--patch | -p) [] [--] [...]
 'git reset' [--soft | --mixed | --hard | --merge | --keep] [-q] []
+'git reset' [--stage | --work] [-q] []
 
 DESCRIPTION
 ---
@@ -81,6 +82,13 @@ but carries forward unmerged index entries.
different between  and HEAD.
If a file that is different between  and HEAD has local changes,
reset is aborted.
+
+--stage::
+   Reset the index, basically `--mixed`. `--no-stage` is the equivalent of
+   `--soft`.
+
+--work::
+   Resets the working tree, basically `--hard`.
 --
 
 If you want to undo a commit other than the latest on a branch,
diff --git a/builtin/reset.c b/builtin/reset.c
index afa6e02..fbc1abc 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -23,6 +23,7 @@
 
 static const char * const git_reset_usage[] = {
N_("git reset [--mixed | --soft | --hard | --merge | --keep] [-q] 
[]"),
+   N_("git reset [--stage | --work] [-q] []"),
N_("git reset [-q]  [--] ..."),
N_("git reset --patch [] [--] [...]"),
NULL
@@ -243,6 +244,7 @@ static int update_refs(const char *rev, const unsigned char 
*sha1)
 int cmd_reset(int argc, const char **argv, const char *prefix)
 {
int reset_type = NONE, update_ref_status = 0, quiet = 0;
+   int stage = -1, working_tree = -1;
int patch_mode = 0, unborn;
const char *rev;
unsigned char sha1[20];
@@ -258,6 +260,8 @@ int cmd_reset(int argc, const char **argv, const char 
*prefix)
N_("reset HEAD, index and working tree"), 
MERGE),
OPT_SET_INT(0, "keep", &reset_type,
N_("reset HEAD but keep local changes"), KEEP),
+   OPT_BOOL(0, "stage", &stage, N_("reset index")),
+   OPT_BOOL(0, "work", &working_tree, N_("reset working tree")),
OPT_BOOLEAN('p', "patch", &patch_mode, N_("select hunks 
interactively")),
OPT_END()
};
@@ -290,6 +294,22 @@ int cmd_reset(int argc, const char **argv, const char 
*prefix)
hashcpy(sha1, tree->object.sha1);
}
 
+   if (stage >= 0 || working_tree >= 0) {
+   if (reset_type != NONE)
+   die(_("--{stage,work} are incompatible with 
--{hard,mixed,soft,merge}"));
+
+   if (working_tree == 1) {
+   if (stage == 0)
+   die(_("--no-stage doesn't make sense with 
--work"));
+   reset_type = HARD;
+   } else {
+   if (stage == 1)
+   reset_type = NONE;
+   else
+   reset_type = SOFT;
+   }
+   }
+
if (patch_mode) {
if (reset_type != NONE)
die(_("--patch is incompatible with 
--{hard,mixed,soft}"));
-- 
1.8.4-fc

--
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 try2 04/14] grep: add --staged option

2013-10-12 Thread Felipe Contreras
Synonym for --cached.

Signed-off-by: Felipe Contreras 
---
 Documentation/git-grep.txt | 5 -
 builtin/grep.c | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt
index 8497aa4..9f7899c 100644
--- a/Documentation/git-grep.txt
+++ b/Documentation/git-grep.txt
@@ -25,7 +25,7 @@ SYNOPSIS
   [-W | --function-context]
   [-f ] [-e] 
   [--and|--or|--not|(|)|-e ...]
-  [ [--[no-]exclude-standard] [--cached | --no-index | --untracked] | 
...]
+  [ [--[no-]exclude-standard] [--cached | --staged | --no-index | 
--untracked] | ...]
   [--] [...]
 
 DESCRIPTION
@@ -60,6 +60,9 @@ OPTIONS
Instead of searching tracked files in the working tree, search
blobs registered in the index file.
 
+--staged::
+   Synonym for `--cached`.
+
 --no-index::
Search files in the current directory that is not managed by Git.
 
diff --git a/builtin/grep.c b/builtin/grep.c
index d3b3b1d..b953911 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -640,6 +640,8 @@ int cmd_grep(int argc, const char **argv, const char 
*prefix)
struct option options[] = {
OPT_BOOLEAN(0, "cached", &cached,
N_("search in index instead of in the work tree")),
+   OPT_BOOLEAN(0, "staged", &cached,
+   N_("search in index instead of in the work tree")),
OPT_NEGBIT(0, "no-index", &use_index,
 N_("find in contents not managed by git"), 1),
OPT_BOOLEAN(0, "untracked", &untracked,
-- 
1.8.4-fc

--
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 try2 01/14] Add proper 'stage' command

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 Documentation/git-stage.txt| 45 +
 Makefile   |  2 +-
 builtin.h  |  1 +
 builtin/stage.c| 52 ++
 contrib/completion/git-completion.bash | 24 +++-
 git.c  |  2 +-
 6 files changed, 118 insertions(+), 8 deletions(-)
 create mode 100644 builtin/stage.c

diff --git a/Documentation/git-stage.txt b/Documentation/git-stage.txt
index ba3fe0d..318bf45 100644
--- a/Documentation/git-stage.txt
+++ b/Documentation/git-stage.txt
@@ -3,20 +3,55 @@ git-stage(1)
 
 NAME
 
-git-stage - Add file contents to the staging area
+git-stage - manage the staging area
 
 
 SYNOPSIS
 
 [verse]
-'git stage' args...
-
+'git stage' [options] [--] [...]
+'git stage add' [options] [--] [...]
+'git stage reset' [-q|--patch] [--] [...]
+'git stage diff' [options] [] [--] [...]
+'git stage rm' [options] [--] [...]
+'git stage apply' [options] [--] [...]
 
 DESCRIPTION
 ---
 
-This is a synonym for linkgit:git-add[1].  Please refer to the
-documentation of that command.
+
+COMMANDS
+
+
+With no arguments, it's a synonym for linkgit:git-add[1].
+
+'add'::
+
+Adds file contents to the staging area. See linkgit:git-add[1].
+
+'reset'::
+
+Resets the staging area. See linkgit:git-reset[1].
+
+'diff'::
+
+View the changes you staged for the next commit. See linkgit:git-diff[1] 
--staged.
+
+'rm'::
+
+Remove files from the staging area only. See linkgit:git-rm[1] --staged.
+
+'apply'::
+
+Apply a patch to the staging area. See linkgit:git-rm[1] --staged.
+
+SEE ALSO
+
+linkgit:git-add[1]
+linkgit:git-reset[1]
+linkgit:git-diff[1]
+linkgit:git-rm[1]
+linkgit:git-apply[1]
 
 GIT
 ---
diff --git a/Makefile b/Makefile
index 3588ca1..1f7ddf3 100644
--- a/Makefile
+++ b/Makefile
@@ -598,7 +598,6 @@ BUILT_INS += git-merge-subtree$X
 BUILT_INS += git-peek-remote$X
 BUILT_INS += git-repo-config$X
 BUILT_INS += git-show$X
-BUILT_INS += git-stage$X
 BUILT_INS += git-status$X
 BUILT_INS += git-whatchanged$X
 
@@ -982,6 +981,7 @@ BUILTIN_OBJS += builtin/send-pack.o
 BUILTIN_OBJS += builtin/shortlog.o
 BUILTIN_OBJS += builtin/show-branch.o
 BUILTIN_OBJS += builtin/show-ref.o
+BUILTIN_OBJS += builtin/stage.o
 BUILTIN_OBJS += builtin/stripspace.o
 BUILTIN_OBJS += builtin/symbolic-ref.o
 BUILTIN_OBJS += builtin/tag.o
diff --git a/builtin.h b/builtin.h
index 8afa2de..baf3a0f 100644
--- a/builtin.h
+++ b/builtin.h
@@ -113,6 +113,7 @@ extern int cmd_send_pack(int argc, const char **argv, const 
char *prefix);
 extern int cmd_shortlog(int argc, const char **argv, const char *prefix);
 extern int cmd_show(int argc, const char **argv, const char *prefix);
 extern int cmd_show_branch(int argc, const char **argv, const char *prefix);
+extern int cmd_stage(int argc, const char **argv, const char *prefix);
 extern int cmd_status(int argc, const char **argv, const char *prefix);
 extern int cmd_stripspace(int argc, const char **argv, const char *prefix);
 extern int cmd_symbolic_ref(int argc, const char **argv, const char *prefix);
diff --git a/builtin/stage.c b/builtin/stage.c
new file mode 100644
index 000..3023d17
--- /dev/null
+++ b/builtin/stage.c
@@ -0,0 +1,52 @@
+/*
+ * 'git stage' builtin command
+ *
+ * Copyright (C) 2013 Felipe Contreras
+ */
+
+#include "builtin.h"
+#include "parse-options.h"
+
+static const char *const stage_usage[] = {
+   N_("git stage [options] [--] ..."),
+   N_("git stage add [options] [--] ..."),
+   N_("git stage reset [-q|--patch] [--] ..."),
+   N_("git stage diff [options] [ [--] ..."),
+   N_("git stage rm [options] [--] ..."),
+   NULL
+};
+
+int cmd_stage(int argc, const char **argv, const char *prefix)
+{
+   struct option options[] = { OPT_END() };
+
+   argc = parse_options(argc, argv, prefix, options, stage_usage,
+   PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN | 
PARSE_OPT_KEEP_DASHDASH);
+
+   if (argc > 1) {
+   if (!strcmp(argv[1], "add"))
+   return cmd_add(argc - 1, argv + 1, prefix);
+   if (!strcmp(argv[1], "reset"))
+   return cmd_reset(argc - 1, argv + 1, prefix);
+   if (!strcmp(argv[1], "diff")) {
+   argv[0] = "diff";
+   argv[1] = "--staged";
+
+   return cmd_diff(argc, argv, prefix);
+   }
+   if (!strcmp(argv[1], "rm")) {
+   argv[0] = "rm";
+   argv[1] = "--cached";
+
+   return cmd_rm(argc, argv, prefix);
+   }
+   if (!strcmp(argv[1], "apply")) {
+   argv[0] = "apply";
+   argv[1] = "--cached";
+
+   return cmd_apply(argc, argv, prefix);
+   }
+   }
+
+   return cmd_

[PATCH 13/20] transport-helper: trivial style fix

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 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-fc

--
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 v3 03/10] transport-helper: check for 'forced update' message

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

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

diff --git a/transport-helper.c b/transport-helper.c
index ed3384e..46b3e57 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -630,7 +630,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;
@@ -683,6 +683,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)
@@ -704,6 +709,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-fc

--
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 18/20] run-command: trivial style fixes

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 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-fc

--
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/20] pretty: trivial style fix

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 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-fc

--
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 try2 4/8] Add concept of 'publish' branch

2013-10-12 Thread Felipe Contreras
The upstream branch is:

  branch.$name.remote
  branch.$name.merge

The publish branch is:

  branch.$name.pushremote
  branch.$name.push

Signed-off-by: Felipe Contreras 
---
 builtin/push.c | 19 +++
 remote.c   | 34 --
 remote.h   |  4 
 3 files changed, 47 insertions(+), 10 deletions(-)

diff --git a/builtin/push.c b/builtin/push.c
index 5dc06a3..f2deddf 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -150,6 +150,20 @@ static void setup_push_current(struct remote *remote, 
struct branch *branch)
add_refspec(branch->name);
 }
 
+static void setup_push_simple(struct remote *remote, struct branch *branch,
+   int triangular)
+{
+   if (branch->push_name) {
+   struct strbuf refspec = STRBUF_INIT;
+   strbuf_addf(&refspec, "%s:%s", branch->name, branch->push_name);
+   add_refspec(refspec.buf);
+   } else if (triangular) {
+   setup_push_current(remote, branch);
+   } else {
+   setup_push_upstream(remote, branch, triangular);
+   }
+}
+
 static char warn_unspecified_push_default_msg[] =
 N_("push.default is unset; its implicit value is changing in\n"
"Git 2.0 from 'matching' to 'simple'. To squelch this message\n"
@@ -210,10 +224,7 @@ static void setup_default_push_refspecs(struct remote 
*remote)
break;
 
case PUSH_DEFAULT_SIMPLE:
-   if (triangular)
-   setup_push_current(remote, get_current_branch(remote));
-   else
-   setup_push_upstream(remote, get_current_branch(remote), 
triangular);
+   setup_push_simple(remote, get_current_branch(remote), 
triangular);
break;
 
case PUSH_DEFAULT_UPSTREAM:
diff --git a/remote.c b/remote.c
index efcba93..04c7ed9 100644
--- a/remote.c
+++ b/remote.c
@@ -350,13 +350,17 @@ static int handle_config(const char *key, const char 
*value, void *cb)
explicit_default_remote_name = 1;
}
} else if (!strcmp(subkey, ".pushremote")) {
+   if (git_config_string(&branch->pushremote_name, key, 
value))
+   return -1;
if (branch == current_branch)
-   if (git_config_string(&pushremote_name, key, 
value))
-   return -1;
+   pushremote_name = 
xstrdup(branch->pushremote_name);
} else if (!strcmp(subkey, ".merge")) {
if (!value)
return config_error_nonbool(key);
add_merge(branch, xstrdup(value));
+   } else if (!strcmp(subkey, ".push")) {
+   if (git_config_string(&branch->push_name, key, value))
+   return -1;
}
return 0;
}
@@ -1492,6 +1496,14 @@ struct branch *branch_get(const char *name)
}
}
}
+   if (ret && ret->pushremote_name) {
+   struct remote *pushremote;
+   pushremote = pushremote_get(ret->pushremote_name);
+   ret->push.src = xstrdup(ret->push_name);
+   if (remote_find_tracking(pushremote, &ret->push)
+   && !strcmp(ret->pushremote_name, "."))
+   ret->push.dst = xstrdup(ret->push_name);
+   }
return ret;
 }
 
@@ -1694,6 +1706,15 @@ int ref_newer(const unsigned char *new_sha1, const 
unsigned char *old_sha1)
return found;
 }
 
+static char *get_base(struct branch *branch)
+{
+   if (branch->push.dst)
+   return branch->push.dst;
+   if (branch->merge && branch->merge[0] && branch->merge[0]->dst)
+   return branch->merge[0]->dst;
+   return NULL;
+}
+
 /*
  * Return true if there is anything to report, otherwise false.
  */
@@ -1710,15 +1731,16 @@ int stat_tracking_info(struct branch *branch, int 
*num_ours, int *num_theirs)
 * Nothing to report unless we are marked to build on top of
 * somebody else.
 */
-   if (!branch ||
-   !branch->merge || !branch->merge[0] || !branch->merge[0]->dst)
+   if (!branch)
+   return 0;
+   base = get_base(branch);
+   if (!base)
return 0;
 
/*
 * If what we used to build on no longer exists, there is
 * nothing to report.
 */
-   base = branch->merge[0]->dst;
if (read_ref(base, sha1))
return 0;
theirs = lookup_commit_reference(sha1);
@@ -1781,7 +1803,7 @@ int format_tracking_info(struct branch *branch, struct 
strbuf *sb)
if (!stat_tracking_info(branch, &num_ours, &num_theirs))
return 0;
 
-   base = branch->merge[0]->dst;
+   base = get_base(branch);
   

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

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

No functional changes.

Signed-off-by: Felipe Contreras 
---
 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 6fca193..3864388 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-fc

--
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 v10 09/15] contrib: related: add support for more roles

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 contrib/related/git-related| 14 --
 contrib/related/test-related.t |  8 
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/contrib/related/git-related b/contrib/related/git-related
index 04c56f5..f94f5f4 100755
--- a/contrib/related/git-related
+++ b/contrib/related/git-related
@@ -8,6 +8,13 @@ $min_percent = 10
 $files = []
 $rev_args = []
 
+KNOWN_ROLES = {
+  'Signed-off-by' => :signer,
+  'Reviewed-by' => :reviewer,
+  'Acked-by' => :acker,
+  'Cc' => :cced,
+}
+
 class Person
 
   attr_reader :roles
@@ -77,9 +84,12 @@ class Commit
   in_body = true
 end
   else
-if line =~ /^(Signed-off-by|Reviewed-by|Acked-by|Cc): ([^<>]+) 
<(\S+?)>$/
+role_regex = KNOWN_ROLES.keys.join('|')
+if line =~ /^(#{role_regex}): ([^<>]+) <(\S+?)>$/
   person = Persons.get($2, $3)
-  person.add_role(@id, :signer) if person != author
+  role = KNOWN_ROLES[$1]
+  next if role == :signer and person == author
+  person.add_role(@id, role)
 end
   end
 end
diff --git a/contrib/related/test-related.t b/contrib/related/test-related.t
index 90cc516..9da2693 100755
--- a/contrib/related/test-related.t
+++ b/contrib/related/test-related.t
@@ -46,7 +46,7 @@ test_expect_success "others" "
cat > expected <<-EOF &&
John Doe  (author: 33%)
John Poppins  (author: 33%)
-   Jon Stewart  (signer: 33%, author: 33%)
+   Jon Stewart  (reviewer: 33%, author: 33%)
EOF
test_cmp expected actual
 "
@@ -58,7 +58,7 @@ test_expect_success "multiple patches" "
cat > expected <<-EOF &&
John Doe  (author: 25%)
John Poppins  (author: 25%)
-   Jon Stewart  (signer: 25%, author: 25%)
+   Jon Stewart  (reviewer: 25%, author: 25%)
Pablo Escobar  (author: 25%)
EOF
test_cmp expected actual
@@ -69,7 +69,7 @@ test_expect_success "from committish" "
cat > expected <<-EOF &&
John Doe  (author: 33%)
John Poppins  (author: 33%)
-   Jon Stewart  (signer: 33%, author: 33%)
+   Jon Stewart  (reviewer: 33%, author: 33%)
EOF
test_cmp expected actual
 "
@@ -79,7 +79,7 @@ test_expect_success "from single rev committish" "
cat > expected <<-EOF &&
John Doe  (author: 33%)
John Poppins  (author: 33%)
-   Jon Stewart  (signer: 33%, author: 33%)
+   Jon Stewart  (reviewer: 33%, author: 33%)
EOF
test_cmp expected actual
 "
-- 
1.8.4-fc

--
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 v10 08/15] contrib: related: show role count

2013-10-12 Thread Felipe Contreras
Instead of showing the total involvement, show it per role: author, or
signer.

Signed-off-by: Felipe Contreras 
---
 contrib/related/git-related| 18 +-
 contrib/related/test-related.t | 30 +++---
 2 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/contrib/related/git-related b/contrib/related/git-related
index 3cac925..04c56f5 100755
--- a/contrib/related/git-related
+++ b/contrib/related/git-related
@@ -16,10 +16,12 @@ class Person
 @name = name
 @email = email
 @commits = {}
+@roles = Hash.new(0)
   end
 
-  def add_role(commit)
+  def add_role(commit, role)
 @commits[commit] = true
+@roles[role] += 1
   end
 
   def <=>(b)
@@ -64,20 +66,20 @@ class Commit
   end
 
   def parse(data)
-in_body = nil
+in_body = author = nil
 data.each_line do |line|
   if not in_body
 case line
 when /^author ([^<>]+) <(\S+)> (.+)$/
   author = Persons.get($1, $2)
-  author.add_role(@id)
+  author.add_role(@id, :author)
 when /^$/
   in_body = true
 end
   else
 if line =~ /^(Signed-off-by|Reviewed-by|Acked-by|Cc): ([^<>]+) 
<(\S+?)>$/
   person = Persons.get($2, $3)
-  person.add_role(@id)
+  person.add_role(@id, :signer) if person != author
 end
   end
 end
@@ -204,5 +206,11 @@ persons = Persons.new
 persons.sort.reverse.each do |person|
   percent = person.size.to_f * 100 / commits.size
   next if percent < $min_percent
-  puts '%s (involved: %u%%)' % [person, percent]
+
+  roles = person.roles.map do |role, role_count|
+role_percent = role_count.to_f * 100 / commits.size
+'%s: %u%%' % [role, role_percent]
+  end
+
+  puts '%s (%s)' % [person, roles.join(', ')]
 end
diff --git a/contrib/related/test-related.t b/contrib/related/test-related.t
index ec2680a..90cc516 100755
--- a/contrib/related/test-related.t
+++ b/contrib/related/test-related.t
@@ -34,8 +34,8 @@ test_expect_success "basic" "
git format-patch --stdout -1 basic > patch &&
git related patch | sort > actual &&
cat > expected <<-EOF &&
-   Jon Stewart  (involved: 50%)
-   Pablo Escobar  (involved: 50%)
+   Jon Stewart  (author: 50%)
+   Pablo Escobar  (author: 50%)
EOF
test_cmp expected actual
 "
@@ -44,9 +44,9 @@ test_expect_success "others" "
git format-patch --stdout -1 master > patch &&
git related patch | sort > actual &&
cat > expected <<-EOF &&
-   John Doe  (involved: 33%)
-   John Poppins  (involved: 33%)
-   Jon Stewart  (involved: 66%)
+   John Doe  (author: 33%)
+   John Poppins  (author: 33%)
+   Jon Stewart  (signer: 33%, author: 33%)
EOF
test_cmp expected actual
 "
@@ -56,10 +56,10 @@ test_expect_success "multiple patches" "
git format-patch --stdout -1 master^ > patch2 &&
git related patch1 patch2 | sort > actual &&
cat > expected <<-EOF &&
-   John Doe  (involved: 25%)
-   John Poppins  (involved: 25%)
-   Jon Stewart  (involved: 50%)
-   Pablo Escobar  (involved: 25%)
+   John Doe  (author: 25%)
+   John Poppins  (author: 25%)
+   Jon Stewart  (signer: 25%, author: 25%)
+   Pablo Escobar  (author: 25%)
EOF
test_cmp expected actual
 "
@@ -67,9 +67,9 @@ test_expect_success "multiple patches" "
 test_expect_success "from committish" "
git related -1 master | sort > actual &&
cat > expected <<-EOF &&
-   John Doe  (involved: 33%)
-   John Poppins  (involved: 33%)
-   Jon Stewart  (involved: 66%)
+   John Doe  (author: 33%)
+   John Poppins  (author: 33%)
+   Jon Stewart  (signer: 33%, author: 33%)
EOF
test_cmp expected actual
 "
@@ -77,9 +77,9 @@ test_expect_success "from committish" "
 test_expect_success "from single rev committish" "
git related -1 master | sort > actual &&
cat > expected <<-EOF &&
-   John Doe  (involved: 33%)
-   John Poppins  (involved: 33%)
-   Jon Stewart  (involved: 66%)
+   John Doe  (author: 33%)
+   John Poppins  (author: 33%)
+   Jon Stewart  (signer: 33%, author: 33%)
EOF
test_cmp expected actual
 "
-- 
1.8.4-fc

--
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 try2 09/14] apply: add --stage option

2013-10-12 Thread Felipe Contreras
Synonym for --index.

Signed-off-by: Felipe Contreras 
---
 Documentation/git-apply.txt | 5 -
 builtin/apply.c | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/Documentation/git-apply.txt b/Documentation/git-apply.txt
index f605327..ce44327 100644
--- a/Documentation/git-apply.txt
+++ b/Documentation/git-apply.txt
@@ -12,7 +12,7 @@ SYNOPSIS
 'git apply' [--stat] [--numstat] [--summary] [--check] [--index] [--3way]
  [--apply] [--no-add] [--build-fake-ancestor=] [-R | --reverse]
  [--allow-binary-replacement | --binary] [--reject] [-z]
- [-p] [-C] [--inaccurate-eof] [--recount] [--cached]
+ [-p] [-C] [--inaccurate-eof] [--recount] [--cached|--staged]
  [--ignore-space-change | --ignore-whitespace ]
  [--whitespace=(nowarn|warn|fix|error|error-all)]
  [--exclude=] [--include=] [--directory=]
@@ -67,6 +67,9 @@ OPTIONS
up-to-date, it is flagged as an error.  This flag also
causes the index file to be updated.
 
+--staged::
+   Synonym for --index.
+
 --cached::
Apply a patch without touching the working tree. Instead take the
cached data, apply the patch, and store the result in the index
diff --git a/builtin/apply.c b/builtin/apply.c
index 50912c9..42b5a4b 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -4377,6 +4377,8 @@ int cmd_apply(int argc, const char **argv, const char 
*prefix_)
N_("instead of applying the patch, see if the patch is 
applicable")),
OPT_BOOLEAN(0, "index", &check_index,
N_("make sure the patch is applicable to the current 
index")),
+   OPT_BOOLEAN(0, "stage", &check_index,
+   N_("make sure the patch is applicable to the current 
index")),
OPT_BOOLEAN(0, "cached", &cached,
N_("apply a patch without touching the working tree")),
OPT_BOOLEAN(0, "apply", &force_apply,
-- 
1.8.4-fc

--
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/20] pull: cleanup documentation

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

Signed-off-by: Felipe Contreras 
---
 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-fc

--
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/20] shortlog: add missing declaration

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

Signed-off-by: Felipe Contreras 
---
 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-fc

--
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 20/20] add: avoid yoda conditions

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 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-fc

--
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 19/20] setup: trivial style fixes

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 setup.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/setup.c b/setup.c
index f08dd64..c717db4 100644
--- a/setup.c
+++ b/setup.c
@@ -566,7 +566,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;
@@ -581,7 +581,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-fc

--
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 try2 0/8] Introduce publish tracking branch

2013-10-12 Thread Felipe Contreras
As it has been discussed before, our support for triangular workflows is
lacking, and the following patch series aims to improve that situation.

We have the concept of upstream branch (e.g. 'origin/master') which is to where
our topic branches eventually should be merged to, so it makes sense that
'git rebase' uses that as the destination, but most people would not push to
such upstream branch, they would push to a publish branch
(e.g.  'github/feature-a'). We could set our upstream to the place we push, and
'git push' would be able to use that as default, and 'git branch --vv' would
show how ahead/behind we are in comparisson to that branch, but then 'git
rebase' (or 'git merge') would be using the wrong branch.

This patch series adds:

 1) git push --set-publish
 2) git branch --set-publish
 3) git branch -vv # uses and shows the publish branch when configured

After this, it becomes much easier to track branches in a triangular workflow.

  master  e230c56 [origin/master, gh/master] Git 1.8.4
* fc/publish  0a105fd [master, gh/fc/publish: ahead 1] branch: display 
publish branch
  fc/branch/fast  177dcad [master, gh/fc/branch/fast] branch: reorganize 
verbose options
  fc/trivial  f289b9a [master: ahead 7] branch: trivial style fix
  fc/leaksd101af4 [master: ahead 2] read-cache: plug a possible leak
  stable  e230c56 Git 1.8.4

Felipe Contreras (8):
  branch: trivial cleanup
  branch: reorganize verbose options
  push: trivial reorganization
  Add concept of 'publish' branch
  branch: allow configuring the publish branch
  t: branch add publish branch tests
  push: add --set-publish option
  branch: display publish branch

 Documentation/git-branch.txt |  11 +
 Documentation/git-push.txt   |   9 +++-
 branch.c |  43 +
 branch.h |   2 +
 builtin/branch.c | 107 +--
 builtin/push.c   |  52 +
 remote.c |  34 +++---
 remote.h |   4 ++
 t/t3200-branch.sh|  76 ++
 t/t5529-push-publish.sh  |  70 
 t/t6040-tracking-info.sh |   8 ++--
 transport.c  |  28 +++
 transport.h  |   1 +
 13 files changed, 393 insertions(+), 52 deletions(-)
 create mode 100755 t/t5529-push-publish.sh

-- 
1.8.4-fc

--
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 v10 01/15] Add new git-related helper to contrib

2013-10-12 Thread Felipe Contreras
This script find people that might be interested in a patch, by going
back through the history for each single hunk modified, and finding
people that reviewed, acknowledge, signed, or authored the code the
patch is modifying.

It does this by running 'git blame' incrementally on each hunk, and then
parsing the commit message. After gathering all the relevant people, it
groups them to show what exactly was their role when the participated in
the development of the relevant commit, and on how many relevant commits
they participated. They are only displayed if they pass a minimum
threshold of participation.

For example:

  % git related 0001-remote-hg-trivial-cleanups.patch
  Felipe Contreras 
  Jeff King 
  Max Horn 
  Junio C Hamano 

Thus it can be used for 'git send-email' as a cc-cmd.

There might be some other related functions to this script, not just to
be used as a cc-cmd.

Comments-by: Ramkumar Ramachandra 
Signed-off-by: Felipe Contreras 
---
 contrib/related/git-related | 120 
 1 file changed, 120 insertions(+)
 create mode 100755 contrib/related/git-related

diff --git a/contrib/related/git-related b/contrib/related/git-related
new file mode 100755
index 000..66c1009
--- /dev/null
+++ b/contrib/related/git-related
@@ -0,0 +1,120 @@
+#!/usr/bin/env ruby
+
+# This script finds people that might be interested in a patch
+# usage: git related 
+
+$since = '5-years-ago'
+$min_percent = 10
+
+class Commit
+
+  attr_reader :persons
+
+  def initialize(id)
+@id = id
+@persons = []
+  end
+
+  def parse(data)
+in_body = nil
+data.each_line do |line|
+  if not in_body
+case line
+when /^author ([^<>]+) <(\S+)> (.+)$/
+  @persons << '%s <%s>' % [$1, $2]
+when /^$/
+  in_body = true
+end
+  else
+if line =~ /^(Signed-off-by|Reviewed-by|Acked-by|Cc): ([^<>]+) 
<(\S+?)>$/
+  @persons << '%s <%s>' % [$2, $3]
+end
+  end
+end
+@persons.uniq!
+  end
+
+end
+
+class Commits
+
+  def initialize
+@items = {}
+  end
+
+  def size
+@items.size
+  end
+
+  def each(&block)
+@items.each(&block)
+  end
+
+  def import
+return if @items.empty?
+File.popen(%w[git cat-file --batch], 'r+') do |p|
+  p.write(@items.keys.join("\n"))
+  p.close_write
+  p.each do |line|
+if line =~ /^(\h{40}) commit (\d+)/
+  id, len = $1, $2
+  data = p.read($2.to_i)
+  @items[id].parse(data)
+end
+  end
+end
+  end
+
+  def get_blame(source, start, len, from)
+return if len == 0
+len ||= 1
+File.popen(['git', 'blame', '--incremental', '-C', '-C',
+   '-L', '%u,+%u' % [start, len],
+   '--since', $since, from + '^',
+   '--', source]) do |p|
+  p.each do |line|
+if line =~ /^\h{40}/
+  id = $&
+  @items[id] ||= Commit.new(id)
+end
+  end
+end
+  end
+
+  def from_patch(file)
+from = source = nil
+File.open(file) do |f|
+  f.each do |line|
+case line
+when /^From (\h+) (.+)$/
+  from = $1
+when /^---\s+(\S+)/
+  source = $1 != '/dev/null' ? $1[2..-1] : nil
+when /^@@ -(\d+)(?:,(\d+))?/
+  get_blame(source, $1, $2, from) if source and from
+end
+  end
+end
+  end
+
+end
+
+exit 1 if ARGV.size != 1
+
+commits = Commits.new
+commits.from_patch(ARGV[0])
+commits.import
+
+count_per_person = Hash.new(0)
+
+commits.each do |id, commit|
+  commit.persons.each do |person|
+count_per_person[person] += 1
+  end
+end
+
+count_per_person.each do |person, count|
+  percent = count.to_f * 100 / commits.size
+  next if percent < $min_percent
+  puts person
+end
-- 
1.8.4-fc

--
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 v10 03/15] contrib: related: add support for multiple patches

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 contrib/related/git-related| 35 +++
 contrib/related/test-related.t | 13 +
 2 files changed, 32 insertions(+), 16 deletions(-)

diff --git a/contrib/related/git-related b/contrib/related/git-related
index 66c1009..7e79d78 100755
--- a/contrib/related/git-related
+++ b/contrib/related/git-related
@@ -1,7 +1,7 @@
 #!/usr/bin/env ruby
 
 # This script finds people that might be interested in a patch
-# usage: git related 
+# usage: git related 
 
 $since = '5-years-ago'
 $min_percent = 10
@@ -40,6 +40,7 @@ class Commits
 
   def initialize
 @items = {}
+@main_commits = {}
   end
 
   def size
@@ -75,23 +76,27 @@ class Commits
   p.each do |line|
 if line =~ /^\h{40}/
   id = $&
-  @items[id] ||= Commit.new(id)
+  @items[id] ||= Commit.new(id) if not @main_commits.include?(id)
 end
   end
 end
   end
 
-  def from_patch(file)
-from = source = nil
-File.open(file) do |f|
-  f.each do |line|
-case line
-when /^From (\h+) (.+)$/
-  from = $1
-when /^---\s+(\S+)/
-  source = $1 != '/dev/null' ? $1[2..-1] : nil
-when /^@@ -(\d+)(?:,(\d+))?/
-  get_blame(source, $1, $2, from) if source and from
+  def from_patches(files)
+source = nil
+files.each do |file|
+  from = nil
+  File.open(file) do |f|
+f.each do |line|
+  case line
+  when /^From (\h+) (.+)$/
+from = $1
+@main_commits[from] = true
+  when /^---\s+(\S+)/
+source = $1 != '/dev/null' ? $1[2..-1] : nil
+  when /^@@ -(\d+)(?:,(\d+))?/
+get_blame(source, $1, $2, from) if source and from
+  end
 end
   end
 end
@@ -99,10 +104,8 @@ class Commits
 
 end
 
-exit 1 if ARGV.size != 1
-
 commits = Commits.new
-commits.from_patch(ARGV[0])
+commits.from_patches(ARGV)
 commits.import
 
 count_per_person = Hash.new(0)
diff --git a/contrib/related/test-related.t b/contrib/related/test-related.t
index b69684d..8102b3c 100755
--- a/contrib/related/test-related.t
+++ b/contrib/related/test-related.t
@@ -51,4 +51,17 @@ test_expect_success "others" "
test_cmp expected actual
 "
 
+test_expect_success "multiple patches" "
+   git format-patch --stdout -1 master > patch1 &&
+   git format-patch --stdout -1 master^ > patch2 &&
+   git related patch1 patch2 | sort > actual &&
+   cat > expected <<-EOF &&
+   John Doe 
+   John Poppins 
+   Jon Stewart 
+   Pablo Escobar 
+   EOF
+   test_cmp expected actual
+"
+
 test_done
-- 
1.8.4-fc

--
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 try2] sha1-name: refactor get_sha1() parsing

2013-10-12 Thread Felipe Contreras
Instead of parsing left to right, do it right do left, this way it is
much more natural and probably efficient too, as there's less
recursivity.

In theory there shouldn't be any functional changes, although there's at
least one error message that has changed.

Signed-off-by: Felipe Contreras 
---
 sha1_name.c| 319 -
 t/t1506-rev-parse-diagnosis.sh |   2 +-
 2 files changed, 185 insertions(+), 136 deletions(-)

diff --git a/sha1_name.c b/sha1_name.c
index 65ad066..e66bda1 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -430,7 +430,6 @@ static inline int upstream_mark(const char *string, int len)
return 0;
 }
 
-static int get_sha1_1(const char *name, int len, unsigned char *sha1, unsigned 
lookup_flags);
 static int interpret_nth_prior_checkout(const char *name, struct strbuf *buf);
 
 static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
@@ -571,29 +570,24 @@ static int get_sha1_basic(const char *str, int len, 
unsigned char *sha1)
return 0;
 }
 
-static int get_parent(const char *name, int len,
- unsigned char *result, int idx)
+static int get_parent(unsigned char *sha1, int idx)
 {
-   unsigned char sha1[20];
-   int ret = get_sha1_1(name, len, sha1, GET_SHA1_COMMITTISH);
struct commit *commit;
struct commit_list *p;
 
-   if (ret)
-   return ret;
commit = lookup_commit_reference(sha1);
if (!commit)
return -1;
if (parse_commit(commit))
return -1;
if (!idx) {
-   hashcpy(result, commit->object.sha1);
+   hashcpy(sha1, commit->object.sha1);
return 0;
}
p = commit->parents;
while (p) {
if (!--idx) {
-   hashcpy(result, p->item->object.sha1);
+   hashcpy(sha1, p->item->object.sha1);
return 0;
}
p = p->next;
@@ -601,16 +595,10 @@ static int get_parent(const char *name, int len,
return -1;
 }
 
-static int get_nth_ancestor(const char *name, int len,
-   unsigned char *result, int generation)
+static int get_nth_ancestor(unsigned char *sha1, int generation)
 {
-   unsigned char sha1[20];
struct commit *commit;
-   int ret;
 
-   ret = get_sha1_1(name, len, sha1, GET_SHA1_COMMITTISH);
-   if (ret)
-   return ret;
commit = lookup_commit_reference(sha1);
if (!commit)
return -1;
@@ -620,7 +608,7 @@ static int get_nth_ancestor(const char *name, int len,
return -1;
commit = commit->parents->item;
}
-   hashcpy(result, commit->object.sha1);
+   hashcpy(sha1, commit->object.sha1);
return 0;
 }
 
@@ -649,12 +637,10 @@ struct object *peel_to_type(const char *name, int namelen,
}
 }
 
-static int peel_onion(const char *name, int len, unsigned char *sha1)
+static int peel_onion(const char *name, const char *str, int len, unsigned 
char *sha1)
 {
-   unsigned char outer[20];
-   const char *sp;
+   const char *sp, *end = NULL;
unsigned int expected_type = 0;
-   unsigned lookup_flags = 0;
struct object *o;
 
/*
@@ -665,18 +651,24 @@ static int peel_onion(const char *name, int len, unsigned 
char *sha1)
 * "ref^{commit}".  "commit^{tree}" could be used to find the
 * top-level tree of the given commit.
 */
-   if (len < 4 || name[len-1] != '}')
-   return -1;
 
-   for (sp = name + len - 1; name <= sp; sp--) {
-   int ch = *sp;
-   if (ch == '{' && name < sp && sp[-1] == '^')
+   if (len < 3)
+   return 0;
+
+   sp = str;
+   if (sp[0] != '^' || sp[1] != '{')
+   return 0;
+
+   for (end = sp; *end; end++)
+   if (*end == '}')
break;
-   }
-   if (sp <= name)
-   return -1;
+   if (!end)
+   return 0;
+
+   end++;
+   len = end - str;
 
-   sp++; /* beginning of type name, or closing brace for empty */
+   sp += 2;
if (!strncmp(commit_type, sp, 6) && sp[6] == '}')
expected_type = OBJ_COMMIT;
else if (!strncmp(tree_type, sp, 4) && sp[4] == '}')
@@ -692,35 +684,28 @@ static int peel_onion(const char *name, int len, unsigned 
char *sha1)
else
return -1;
 
-   if (expected_type == OBJ_COMMIT)
-   lookup_flags = GET_SHA1_COMMITTISH;
-   else if (expected_type == OBJ_TREE)
-   lookup_flags = GET_SHA1_TREEISH;
-
-   if (get_sha1_1(name, sp - name - 2, outer, lookup_flags))
-   return -1;
-
-   o = parse_object(outer);
+   o = parse_object(sha1);
if (!o)
return -1;
if (!expected_type) {
-   o 

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

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

Signed-off-by: Felipe Contreras 
---
 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-fc

--
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 v10 14/15] contrib: related: add option to show commits

2013-10-12 Thread Felipe Contreras
Instead of showing the authors and signers, show the commits themselves.

Signed-off-by: Felipe Contreras 
---
 contrib/related/git-related| 23 +++
 contrib/related/test-related.t | 10 ++
 2 files changed, 33 insertions(+)

diff --git a/contrib/related/git-related b/contrib/related/git-related
index d6b44c7..b9c8619 100755
--- a/contrib/related/git-related
+++ b/contrib/related/git-related
@@ -7,6 +7,7 @@ $since = '5-years-ago'
 $min_percent = 10
 $files = []
 $rev_args = []
+$show_commits = false
 
 $mailmaps = {}
 $mailmaps_complex = {}
@@ -128,6 +129,10 @@ opts.on('d', 'since', 'How far back to search for relevant 
commits') do |v|
   $since = v
 end
 
+opts.on('c', 'commits', 'List commits instead of persons') do |v|
+  $show_commits = v
+end
+
 opts.parse
 
 class Person
@@ -238,6 +243,10 @@ class Commits
 @items.each(&block)
   end
 
+  def list
+@items.keys
+  end
+
   def import
 return if @items.empty?
 File.popen(%w[git cat-file --batch], 'r+') do |p|
@@ -339,6 +348,20 @@ else
 end
 commits.import
 
+if $show_commits
+  cmd = nil
+  case $show_commits
+  when 'raw'
+puts commits.list
+  when 'full'
+cmd = %w[git log --patch --no-walk]
+  else
+cmd = %w[git log --oneline --no-walk]
+  end
+  system(*cmd + commits.list) if cmd
+  exit 0
+end
+
 persons = Persons.new
 
 persons.sort.reverse.each do |person|
diff --git a/contrib/related/test-related.t b/contrib/related/test-related.t
index fa8c1a7..f357e30 100755
--- a/contrib/related/test-related.t
+++ b/contrib/related/test-related.t
@@ -94,4 +94,14 @@ test_expect_success "mailmap" "
test_cmp expected actual
 "
 
+test_expect_success "commits" "
+   git related -craw -1 master | git log --format='%s' --no-walk --stdin > 
actual &&
+   cat > expected <<-EOF &&
+   four
+   three
+   one
+   EOF
+   test_cmp expected actual
+"
+
 test_done
-- 
1.8.4-fc

--
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 v10 12/15] contrib: related: add mailmap support

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 contrib/related/git-related| 37 +
 contrib/related/test-related.t | 14 ++
 2 files changed, 51 insertions(+)

diff --git a/contrib/related/git-related b/contrib/related/git-related
index f15e4e7..6ab74c7 100755
--- a/contrib/related/git-related
+++ b/contrib/related/git-related
@@ -8,6 +8,9 @@ $min_percent = 10
 $files = []
 $rev_args = []
 
+$mailmaps = {}
+$mailmaps_complex = {}
+
 git_dir = %x[git rev-parse --git-dir].chomp
 $base_dir = File.dirname(git_dir)
 $cur_dir = Dir.pwd
@@ -19,6 +22,29 @@ KNOWN_ROLES = {
   'Cc' => :cced,
 }
 
+def get_mailmap(filename)
+  return unless File.exists?(filename)
+  File.open(filename) do |f|
+f.each do |line|
+  case line.gsub(/\s*#.*$/, '')
+  when /^([^<>]+)\s+<(\S+)>$/
+$mailmaps[$2] = [ $1, nil ]
+  when /^<(\S+)>\s+<(\S+)>$/
+$mailmaps[$2] = [ nil, $1 ]
+  when /^([^<>]+)\s+<(\S+)>\s+<(\S+)>$/
+$mailmaps[$3] = [ $1, $2 ]
+  when /^([^<>]+)\s+<(\S+)>\s+([^<>]+)\s+<(\S+)>$/
+$mailmaps_complex[[$3, $4]] = [ $1, $2 ]
+  end
+end
+  end
+end
+
+get_aliases if $get_aliases
+get_mailmap(File.join($base_dir, '.mailmap'))
+mailmap_file = %x[git config mailmap.file].chomp
+get_mailmap(mailmap_file)
+
 class Person
 
   attr_reader :roles
@@ -60,6 +86,17 @@ class Persons
   end
 
   def self.get(name, email)
+
+# fix with mailmap
+person = [name, email]
+new = nil
+new = $mailmaps_complex[person] if not new and 
$mailmaps_complex.include?(person)
+new = $mailmaps[email] if not new and $mailmaps.include?(email)
+if new
+  name = new[0] if new[0]
+  email = new[1] if new[1]
+end
+
 id = email.downcase
 person = @@index[id]
 if not person
diff --git a/contrib/related/test-related.t b/contrib/related/test-related.t
index a19ad32..fa8c1a7 100755
--- a/contrib/related/test-related.t
+++ b/contrib/related/test-related.t
@@ -80,4 +80,18 @@ test_expect_success "from single rev committish" "
test_cmp expected actual
 "
 
+test_expect_success "mailmap" "
+   test_when_finished 'rm -rf .mailmap' &&
+   cat > .mailmap <<-EOF &&
+   Jon McAvoy 
+   John Poppins  
+   EOF
+   git related -1 master | sort > actual &&
+   cat > expected <<-EOF &&
+   John Poppins  (author: 66%)
+   Jon McAvoy  (reviewer: 33%, author: 33%)
+   EOF
+   test_cmp expected actual
+"
+
 test_done
-- 
1.8.4-fc

--
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 v10 07/15] contrib: related: add helper Person classes

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

Signed-off-by: Felipe Contreras 
---
 contrib/related/git-related | 71 +++--
 1 file changed, 56 insertions(+), 15 deletions(-)

diff --git a/contrib/related/git-related b/contrib/related/git-related
index ffce839..3cac925 100755
--- a/contrib/related/git-related
+++ b/contrib/related/git-related
@@ -8,13 +8,59 @@ $min_percent = 10
 $files = []
 $rev_args = []
 
-class Commit
+class Person
+
+  attr_reader :roles
+
+  def initialize(name, email)
+@name = name
+@email = email
+@commits = {}
+  end
+
+  def add_role(commit)
+@commits[commit] = true
+  end
+
+  def <=>(b)
+self.size <=> b.size
+  end
+
+  def size
+@commits.size
+  end
+
+  def to_s
+'%s <%s>' % [@name, @email]
+  end
+
+end
 
-  attr_reader :persons
+class Persons
+
+  @@index = {}
+
+  include Enumerable
+
+  def each(&block)
+@@index.values.each(&block)
+  end
+
+  def self.get(name, email)
+id = [name, email]
+person = @@index[id]
+if not person
+  person = @@index[id] = Person.new(name, email)
+end
+person
+  end
+
+end
+
+class Commit
 
   def initialize(id)
 @id = id
-@persons = []
   end
 
   def parse(data)
@@ -23,17 +69,18 @@ class Commit
   if not in_body
 case line
 when /^author ([^<>]+) <(\S+)> (.+)$/
-  @persons << '%s <%s>' % [$1, $2]
+  author = Persons.get($1, $2)
+  author.add_role(@id)
 when /^$/
   in_body = true
 end
   else
 if line =~ /^(Signed-off-by|Reviewed-by|Acked-by|Cc): ([^<>]+) 
<(\S+?)>$/
-  @persons << '%s <%s>' % [$2, $3]
+  person = Persons.get($2, $3)
+  person.add_role(@id)
 end
   end
 end
-@persons.uniq!
   end
 
 end
@@ -152,16 +199,10 @@ else
 end
 commits.import
 
-count_per_person = Hash.new(0)
-
-commits.each do |id, commit|
-  commit.persons.each do |person|
-count_per_person[person] += 1
-  end
-end
+persons = Persons.new
 
-count_per_person.each do |person, count|
-  percent = count.to_f * 100 / commits.size
+persons.sort.reverse.each do |person|
+  percent = person.size.to_f * 100 / commits.size
   next if percent < $min_percent
   puts '%s (involved: %u%%)' % [person, percent]
 end
-- 
1.8.4-fc

--
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 try2 2/8] branch: reorganize verbose options

2013-10-12 Thread Felipe Contreras
Showing the upstream tracking branch is more important than how many
commits are ahead/behind, so now 'git branch -v' shows the upstream, but
not the tracking info, and 'git branch -vv' shows all information (as
before).

Signed-off-by: Felipe Contreras 
---
 builtin/branch.c | 22 ++
 t/t6040-tracking-info.sh |  8 
 2 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/builtin/branch.c b/builtin/branch.c
index ac17b18..baa1d31 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -417,15 +417,15 @@ static int ref_cmp(const void *r1, const void *r2)
 }
 
 static void fill_tracking_info(struct strbuf *stat, const char *branch_name,
-   int show_upstream_ref)
+   int show_tracking)
 {
int ours, theirs;
char *ref = NULL;
struct branch *branch = branch_get(branch_name);
struct strbuf fancy = STRBUF_INIT;
 
-   if (!stat_tracking_info(branch, &ours, &theirs)) {
-   if (!branch || !branch->merge || !branch->merge[0]->dst || 
!show_upstream_ref)
+   if (!show_tracking || !stat_tracking_info(branch, &ours, &theirs)) {
+   if (!branch || !branch->merge || !branch->merge[0]->dst)
return;
ref = shorten_unambiguous_ref(branch->merge[0]->dst, 0);
if (want_color(branch_use_color))
@@ -437,15 +437,13 @@ static void fill_tracking_info(struct strbuf *stat, const 
char *branch_name,
return;
}
 
-   if (show_upstream_ref) {
-   ref = shorten_unambiguous_ref(branch->merge[0]->dst, 0);
-   if (want_color(branch_use_color))
-   strbuf_addf(&fancy, "%s%s%s",
-   branch_get_color(BRANCH_COLOR_UPSTREAM),
-   ref, 
branch_get_color(BRANCH_COLOR_RESET));
-   else
-   strbuf_addstr(&fancy, ref);
-   }
+   ref = shorten_unambiguous_ref(branch->merge[0]->dst, 0);
+   if (want_color(branch_use_color))
+   strbuf_addf(&fancy, "%s%s%s",
+   branch_get_color(BRANCH_COLOR_UPSTREAM),
+   ref, branch_get_color(BRANCH_COLOR_RESET));
+   else
+   strbuf_addstr(&fancy, ref);
 
if (!ours) {
if (ref)
diff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh
index ec2b516..86e80eb 100755
--- a/t/t6040-tracking-info.sh
+++ b/t/t6040-tracking-info.sh
@@ -36,10 +36,10 @@ test_expect_success setup '
 
 script='s/^..\(b.\)[0-9a-f]*\[\([^]]*\)\].*/\1 \2/p'
 cat >expect <<\EOF
-b1 ahead 1, behind 1
-b2 ahead 1, behind 1
-b3 behind 1
-b4 ahead 2
+b1 origin/master
+b2 origin/master
+b3 origin/master
+b4 origin/master
 EOF
 
 test_expect_success 'branch -v' '
-- 
1.8.4-fc

--
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/20] doc: git-foo was obsoleted several years ago

2013-10-12 Thread Felipe Contreras
So replace 'git-foo' with 'git foo'.

Signed-off-by: Felipe Contreras 
---
 Documentation/git-checkout.txt | 4 ++--
 Documentation/git-commit.txt   | 4 ++--
 Documentation/git-rebase.txt   | 4 ++--
 Documentation/git-status.txt   | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index 91294f8..7560113 100644
--- a/Documentation/git-checkout.txt
+++ b/Documentation/git-checkout.txt
@@ -1,9 +1,9 @@
-git-checkout(1)
+git checkout(1)
 ===
 
 NAME
 
-git-checkout - Checkout a branch or paths to the working tree
+git checkout - Checkout a branch or paths to the working tree
 
 SYNOPSIS
 
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index 1a7616c..51f6b81 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -1,9 +1,9 @@
-git-commit(1)
+git commit(1)
 =
 
 NAME
 
-git-commit - Record changes to the repository
+git commit - Record changes to the repository
 
 SYNOPSIS
 
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 94e07fd..9a8d158 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -1,9 +1,9 @@
-git-rebase(1)
+git rebase(1)
 =
 
 NAME
 
-git-rebase - Forward-port local commits to the updated upstream head
+git rebase - Forward-port local commits to the updated upstream head
 
 SYNOPSIS
 
diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt
index a4acaa0..6fb7561 100644
--- a/Documentation/git-status.txt
+++ b/Documentation/git-status.txt
@@ -1,9 +1,9 @@
-git-status(1)
+git status(1)
 =
 
 NAME
 
-git-status - Show the working tree status
+git status - Show the working tree status
 
 
 SYNOPSIS
-- 
1.8.4-fc

--
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 try2 3/8] push: trivial reorganization

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 builtin/push.c | 35 +++
 1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/builtin/push.c b/builtin/push.c
index 04f0eaf..5dc06a3 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -113,20 +113,11 @@ static NORETURN int die_push_simple(struct branch 
*branch, struct remote *remote
remote->name, branch->name, advice_maybe);
 }
 
-static const char message_detached_head_die[] =
-   N_("You are not currently on a branch.\n"
-  "To push the history leading to the current (detached HEAD)\n"
-  "state now, use\n"
-  "\n"
-  "git push %s HEAD:\n");
-
 static void setup_push_upstream(struct remote *remote, struct branch *branch,
int triangular)
 {
struct strbuf refspec = STRBUF_INIT;
 
-   if (!branch)
-   die(_(message_detached_head_die), remote->name);
if (!branch->merge_nr || !branch->merge || !branch->remote_name)
die(_("The current branch %s has no upstream branch.\n"
"To push the current branch and set the remote as upstream, 
use\n"
@@ -156,8 +147,6 @@ static void setup_push_upstream(struct remote *remote, 
struct branch *branch,
 
 static void setup_push_current(struct remote *remote, struct branch *branch)
 {
-   if (!branch)
-   die(_(message_detached_head_die), remote->name);
add_refspec(branch->name);
 }
 
@@ -191,9 +180,23 @@ static int is_workflow_triangular(struct remote *remote)
return (fetch_remote && fetch_remote != remote);
 }
 
-static void setup_default_push_refspecs(struct remote *remote)
+static const char message_detached_head_die[] =
+   N_("You are not currently on a branch.\n"
+  "To push the history leading to the current (detached HEAD)\n"
+  "state now, use\n"
+  "\n"
+  "git push %s HEAD:\n");
+
+static struct branch *get_current_branch(struct remote *remote)
 {
struct branch *branch = branch_get(NULL);
+   if (!branch)
+   die(_(message_detached_head_die), remote->name);
+   return branch;
+}
+
+static void setup_default_push_refspecs(struct remote *remote)
+{
int triangular = is_workflow_triangular(remote);
 
switch (push_default) {
@@ -208,17 +211,17 @@ static void setup_default_push_refspecs(struct remote 
*remote)
 
case PUSH_DEFAULT_SIMPLE:
if (triangular)
-   setup_push_current(remote, branch);
+   setup_push_current(remote, get_current_branch(remote));
else
-   setup_push_upstream(remote, branch, triangular);
+   setup_push_upstream(remote, get_current_branch(remote), 
triangular);
break;
 
case PUSH_DEFAULT_UPSTREAM:
-   setup_push_upstream(remote, branch, triangular);
+   setup_push_upstream(remote, get_current_branch(remote), 
triangular);
break;
 
case PUSH_DEFAULT_CURRENT:
-   setup_push_current(remote, branch);
+   setup_push_current(remote, get_current_branch(remote));
break;
 
case PUSH_DEFAULT_NOTHING:
-- 
1.8.4-fc

--
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 v10 13/15] contrib: related: add option parsing

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 contrib/related/git-related | 85 +
 1 file changed, 85 insertions(+)

diff --git a/contrib/related/git-related b/contrib/related/git-related
index 6ab74c7..d6b44c7 100755
--- a/contrib/related/git-related
+++ b/contrib/related/git-related
@@ -45,6 +45,91 @@ get_mailmap(File.join($base_dir, '.mailmap'))
 mailmap_file = %x[git config mailmap.file].chomp
 get_mailmap(mailmap_file)
 
+class ParseOpt
+  attr_writer :usage
+
+  class Option
+attr_reader :short, :long, :help
+
+def initialize(short, long, help, &block)
+  @block = block
+  @short = short
+  @long = long
+  @help = help
+end
+
+def call(v)
+  @block.call(v)
+end
+  end
+
+  def initialize
+@list = {}
+  end
+
+  def on(short = nil, long = nil, help = nil, &block)
+opt = Option.new(short, long, help, &block)
+@list[short] = opt if short
+@list[long] = opt if long
+  end
+
+  def parse
+if ARGV.member?('-h') or ARGV.member?('--help')
+  usage
+  exit 0
+end
+seen_dash = false
+ARGV.delete_if do |cur|
+  opt = val = nil
+  next false if cur[0] != '-' or seen_dash
+  case cur
+  when '--'
+seen_dash = true
+next true
+  when /^--no-(.+)$/
+opt = @list[$1]
+val = false
+  when /^-([^-])(.+)?$/, /^--(.+?)(?:=(.+))?$/
+opt = @list[$1]
+val = $2 || true
+  end
+  if opt
+opt.call(val)
+true
+  end
+end
+  end
+
+  def usage
+def fmt(prefix, str)
+  return str ? prefix + str : nil
+end
+puts 'usage: %s' % @usage
+@list.values.uniq.each do |opt|
+  s = ''
+  s << ''
+  s << [fmt('-', opt.short), fmt('--', opt.long)].compact.join(', ')
+  s << ''
+  s << '%*s%s' % [26 - s.size, '', opt.help] if opt.help
+  puts s
+end
+  end
+
+end
+
+opts = ParseOpt.new
+opts.usage = 'git related [options] '
+
+opts.on('p', 'min-percent', 'Minium percentage of role participation') do |v|
+  $min_percent = v.to_i
+end
+
+opts.on('d', 'since', 'How far back to search for relevant commits') do |v|
+  $since = v
+end
+
+opts.parse
+
 class Person
 
   attr_reader :roles
-- 
1.8.4-fc

--
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/20] Trivial paches

2013-10-12 Thread Felipe Contreras


Felipe Contreras (20):
  merge: simplify ff-only option
  t: replace pulls with merges
  pull: cleanup documentation
  fetch: add missing documentation
  remote: fix trivial memory leak
  revision: add missing include
  shortlog: add missing declaration
  branch: trivial style fix
  sha1-name: trivial style cleanup
  doc: git-foo was obsoleted several years ago
  symbolic-ref: trivial style fix
  alias: trivial style fix
  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-checkout.txt |  4 ++--
 Documentation/git-commit.txt   |  4 ++--
 Documentation/git-fetch.txt|  3 +++
 Documentation/git-pull.txt |  4 ++--
 Documentation/git-rebase.txt   |  4 ++--
 Documentation/git-status.txt   |  4 ++--
 alias.c| 13 +++--
 builtin/add.c  |  2 +-
 builtin/branch.c   |  3 +--
 builtin/describe.c |  7 +++
 builtin/diff.c |  2 +-
 builtin/merge.c| 11 ++-
 builtin/symbolic-ref.c |  2 +-
 pretty.c   |  2 +-
 remote.c   |  3 ++-
 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 +
 26 files changed, 53 insertions(+), 59 deletions(-)

-- 
1.8.4-fc

--
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/20] sha1-name: trivial style cleanup

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 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-fc

--
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 try2 10/14] apply: add --work, --no-work options

2013-10-12 Thread Felipe Contreras
'git apply', 'git apply --index', 'git apply --cached' do different
things, but what they do is not precisely clear, specially since no
other commands has similar distinctions.

With --no-work (--work being the default), it's clear what the option
would do; modify, or not, the working directory.

So, --work (the default), doesn't cause any changes, and --no-work
enables the current --cache if used with --index.

Eventually --work might replace --cache, if these options are
standarized in the whole git toolset.

Signed-off-by: Felipe Contreras 
---
 Documentation/git-apply.txt | 6 +-
 builtin/apply.c | 5 +
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/Documentation/git-apply.txt b/Documentation/git-apply.txt
index ce44327..6167061 100644
--- a/Documentation/git-apply.txt
+++ b/Documentation/git-apply.txt
@@ -16,7 +16,7 @@ SYNOPSIS
  [--ignore-space-change | --ignore-whitespace ]
  [--whitespace=(nowarn|warn|fix|error|error-all)]
  [--exclude=] [--include=] [--directory=]
- [--verbose] [...]
+ [--verbose] [--no-work] [...]
 
 DESCRIPTION
 ---
@@ -75,6 +75,10 @@ OPTIONS
cached data, apply the patch, and store the result in the index
without using the working tree. This implies `--index`.
 
+--[no-]work::
+   Apply a patch with or without touching the working tree, essentially
+   `--no-work` plus `--index` are the equivalent of `--cached`.
+
 -3::
 --3way::
When the patch does not apply cleanly, fall back on 3-way merge if
diff --git a/builtin/apply.c b/builtin/apply.c
index 42b5a4b..a3dd89d 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -4350,6 +4350,7 @@ int cmd_apply(int argc, const char **argv, const char 
*prefix_)
int errs = 0;
int is_not_gitdir = !startup_info->have_repository;
int force_apply = 0;
+   int work = 1;
 
const char *whitespace_option = NULL;
 
@@ -4381,6 +4382,8 @@ int cmd_apply(int argc, const char **argv, const char 
*prefix_)
N_("make sure the patch is applicable to the current 
index")),
OPT_BOOLEAN(0, "cached", &cached,
N_("apply a patch without touching the working tree")),
+   OPT_BOOLEAN(0, "work", &work,
+   N_("modify the working tree")),
OPT_BOOLEAN(0, "apply", &force_apply,
N_("also apply the patch (use with 
--stat/--summary/--check)")),
OPT_BOOL('3', "3way", &threeway,
@@ -4433,6 +4436,8 @@ int cmd_apply(int argc, const char **argv, const char 
*prefix_)
argc = parse_options(argc, argv, prefix, builtin_apply_options,
apply_usage, 0);
 
+   if (check_index && !work)
+   cached = 1;
if (apply_with_reject && threeway)
die("--reject and --3way cannot be used together.");
if (cached && threeway)
-- 
1.8.4-fc

--
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/20] branch: trivial style fix

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 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-fc

--
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/20] remote: fix trivial memory leak

2013-10-12 Thread Felipe Contreras
There's no need to set the default remote name beforehand, only to be
overridden later on, and causing a memory leak, we can do it after the
configuration has been handled.

Signed-off-by: Felipe Contreras 
---
 remote.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/remote.c b/remote.c
index e9fedfa..ce9d82a 100644
--- a/remote.c
+++ b/remote.c
@@ -483,7 +483,6 @@ static void read_config(void)
int flag;
if (default_remote_name) /* did this already */
return;
-   default_remote_name = xstrdup("origin");
current_branch = NULL;
head_ref = resolve_ref_unsafe("HEAD", sha1, 0, &flag);
if (head_ref && (flag & REF_ISSYMREF) &&
@@ -492,6 +491,8 @@ static void read_config(void)
make_branch(head_ref + strlen("refs/heads/"), 0);
}
git_config(handle_config, NULL);
+   if (!default_remote_name)
+   default_remote_name = xstrdup("origin");
alias_all_urls();
 }
 
-- 
1.8.4-fc

--
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 v3] revision: add --except option

2013-10-12 Thread Felipe Contreras
So that it's possible to remove certain refs from the list without
removing the objects that are referenced by other refs.

For example this repository:

  C (crap)
  B (test)
  A (HEAD, master)

When using '--branches --except crap':

  B (test)
  A (HEAD, master)

But when using '--branches --not crap' nothing will come out.

Signed-off-by: Felipe Contreras 
---
 Documentation/git-rev-parse.txt|  6 +++
 contrib/completion/git-completion.bash |  2 +-
 revision.c | 54 +++-
 revision.h |  3 +-
 t/t6112-rev-list-except.sh | 77 ++
 5 files changed, 139 insertions(+), 3 deletions(-)
 create mode 100755 t/t6112-rev-list-except.sh

diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt
index 2b126c0..fe5cc6b 100644
--- a/Documentation/git-rev-parse.txt
+++ b/Documentation/git-rev-parse.txt
@@ -110,6 +110,12 @@ can be used.
strip '{caret}' prefix from the object names that already have
one.
 
+--except::
+   Skip the following object names. For example:
+   '--branches --except master' will show all the branches, except master.
+   This differs from --not in that --except will still show the object, if
+   they are referenced by another object name.
+
 --symbolic::
Usually the object names are output in SHA-1 form (with
possible '{caret}' prefix); this option makes them output in a
diff --git a/contrib/completion/git-completion.bash 
b/contrib/completion/git-completion.bash
index 5da920e..aed8c12 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1386,7 +1386,7 @@ _git_ls_tree ()
 
 # Options that go well for log, shortlog and gitk
 __git_log_common_options="
-   --not --all
+   --not --except --all
--branches --tags --remotes
--first-parent --merges --no-merges
--max-count=
diff --git a/revision.c b/revision.c
index 84ccc05..c92f755 100644
--- a/revision.c
+++ b/revision.c
@@ -1984,6 +1984,9 @@ static int handle_revision_pseudo_opt(const char 
*submodule,
handle_reflog(revs, *flags);
} else if (!strcmp(arg, "--not")) {
*flags ^= UNINTERESTING | BOTTOM;
+   *flags &= ~SKIP;
+   } else if (!strcmp(arg, "--except")) {
+   *flags |= SKIP;
} else if (!strcmp(arg, "--no-walk")) {
revs->no_walk = REVISION_WALK_NO_WALK_SORTED;
} else if (!prefixcmp(arg, "--no-walk=")) {
@@ -2573,24 +2576,73 @@ void reset_revision_walk(void)
clear_object_flags(SEEN | ADDED | SHOWN);
 }
 
+static int refcmp(const char *a, const char *b)
+{
+   a = prettify_refname(a);
+   if (*a == '^')
+   a++;
+   b = prettify_refname(b);
+   if (*b == '^')
+   b++;
+   return strcmp(a, b);
+}
+
+static int recalculate_flag(struct rev_info *revs, unsigned char *sha1, const 
char *name)
+{
+   int flags = 0;
+   int i;
+   for (i = 0; i < revs->cmdline.nr; i++) {
+   struct object *object;
+   struct rev_cmdline_entry *ce;
+   ce = &revs->cmdline.rev[i];
+   object = ce->item;
+   while (object->type == OBJ_TAG) {
+   struct tag *tag = (struct tag *) object;
+   if (!tag->tagged)
+   continue;
+   object = parse_object(tag->tagged->sha1);
+   if (!object)
+   continue;
+   }
+   if (hashcmp(object->sha1, sha1))
+   continue;
+   if (!strcmp(ce->name, name))
+   continue;
+   flags |= ce->flags;
+   }
+   return flags;
+}
+
 int prepare_revision_walk(struct rev_info *revs)
 {
int nr = revs->pending.nr;
struct object_array_entry *e, *list;
struct commit_list **next = &revs->commits;
+   int i;
 
e = list = revs->pending.objects;
revs->pending.nr = 0;
revs->pending.alloc = 0;
revs->pending.objects = NULL;
while (--nr >= 0) {
-   struct commit *commit = handle_commit(revs, e->item, e->name);
+   struct commit *commit;
+   for (i = 0; i < revs->cmdline.nr; i++) {
+   struct rev_cmdline_entry *ce;
+   ce = &revs->cmdline.rev[i];
+   if ((ce->flags & SKIP) && !refcmp(ce->name, e->name) &&
+   ((ce->flags & UNINTERESTING) == 
(e->item->flags & UNINTERESTING))) {
+   e->item->flags = recalculate_flag(revs, 
e->item->sha1, ce->name);
+   goto next;
+   }
+   }
+   commit = handle_commit(revs, e->item, e->name);
if (commit) {
 

[PATCH 17/20] diff: trivial style fix

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 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-fc

--
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/20] symbolic-ref: trivial style fix

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 builtin/symbolic-ref.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/symbolic-ref.c b/builtin/symbolic-ref.c
index f481959..71286b4 100644
--- a/builtin/symbolic-ref.c
+++ b/builtin/symbolic-ref.c
@@ -47,7 +47,7 @@ int cmd_symbolic_ref(int argc, const char **argv, const char 
*prefix)
git_config(git_default_config, NULL);
argc = parse_options(argc, argv, prefix, options,
 git_symbolic_ref_usage, 0);
-   if (msg &&!*msg)
+   if (msg && !*msg)
die("Refusing to perform update with empty message");
 
if (delete) {
-- 
1.8.4-fc

--
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 try2 8/8] branch: display publish branch

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 builtin/branch.c | 52 +++-
 1 file changed, 43 insertions(+), 9 deletions(-)

diff --git a/builtin/branch.c b/builtin/branch.c
index cf33e1c..9f15f7e 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -42,6 +42,7 @@ static char branch_colors[][COLOR_MAXLEN] = {
GIT_COLOR_NORMAL,   /* LOCAL */
GIT_COLOR_GREEN,/* CURRENT */
GIT_COLOR_BLUE, /* UPSTREAM */
+   GIT_COLOR_YELLOW,   /* PUBLISH */
 };
 enum color_branch {
BRANCH_COLOR_RESET = 0,
@@ -49,7 +50,8 @@ enum color_branch {
BRANCH_COLOR_REMOTE = 2,
BRANCH_COLOR_LOCAL = 3,
BRANCH_COLOR_CURRENT = 4,
-   BRANCH_COLOR_UPSTREAM = 5
+   BRANCH_COLOR_UPSTREAM = 5,
+   BRANCH_COLOR_PUBLISH = 6
 };
 
 static enum merge_filter {
@@ -76,6 +78,8 @@ static int parse_branch_color_slot(const char *var, int ofs)
return BRANCH_COLOR_CURRENT;
if (!strcasecmp(var+ofs, "upstream"))
return BRANCH_COLOR_UPSTREAM;
+   if (!strcasecmp(var+ofs, "publish"))
+   return BRANCH_COLOR_PUBLISH;
return -1;
 }
 
@@ -424,16 +428,35 @@ static void fill_tracking_info(struct strbuf *stat, const 
char *branch_name,
struct branch *branch = branch_get(branch_name);
struct strbuf fancy = STRBUF_INIT;
 
+   if (!branch)
+   return;
+
if (!show_tracking || !stat_tracking_info(branch, &ours, &theirs)) {
-   if (!branch || !branch->merge || !branch->merge[0]->dst)
+   if (branch->merge && branch->merge[0]->dst) {
+   ref = shorten_unambiguous_ref(branch->merge[0]->dst, 0);
+   if (want_color(branch_use_color))
+   strbuf_addf(&fancy, "%s%s%s",
+   
branch_get_color(BRANCH_COLOR_UPSTREAM),
+   ref, 
branch_get_color(BRANCH_COLOR_RESET));
+   else
+   strbuf_addstr(&fancy, ref);
+   }
+   if (branch->push.dst) {
+   ref = shorten_unambiguous_ref(branch->push.dst, 0);
+   if (fancy.len)
+   strbuf_addstr(&fancy, ", ");
+   if (want_color(branch_use_color))
+   strbuf_addf(&fancy, "%s%s%s",
+   
branch_get_color(BRANCH_COLOR_PUBLISH),
+   ref, 
branch_get_color(BRANCH_COLOR_RESET));
+   else
+   strbuf_addstr(&fancy, ref);
+   }
+   if (!fancy.len)
return;
-   ref = shorten_unambiguous_ref(branch->merge[0]->dst, 0);
-   if (want_color(branch_use_color))
-   strbuf_addf(stat, "[%s%s%s] ",
-   branch_get_color(BRANCH_COLOR_UPSTREAM),
-   ref, 
branch_get_color(BRANCH_COLOR_RESET));
-   else
-   strbuf_addf(stat, "[%s] ", ref);
+   strbuf_addf(stat, _("[%s]"), fancy.buf);
+   strbuf_release(&fancy);
+   strbuf_addch(stat, ' ');
return;
}
 
@@ -444,6 +467,17 @@ static void fill_tracking_info(struct strbuf *stat, const 
char *branch_name,
ref, branch_get_color(BRANCH_COLOR_RESET));
else
strbuf_addstr(&fancy, ref);
+   if (branch->push.dst) {
+   ref = shorten_unambiguous_ref(branch->push.dst, 0);
+   if (fancy.len)
+   strbuf_addstr(&fancy, ", ");
+   if (want_color(branch_use_color))
+   strbuf_addf(&fancy, "%s%s%s",
+   branch_get_color(BRANCH_COLOR_PUBLISH),
+   ref, 
branch_get_color(BRANCH_COLOR_RESET));
+   else
+   strbuf_addstr(&fancy, ref);
+   }
 
if (!ours) {
if (ref)
-- 
1.8.4-fc

--
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 v10 05/15] contrib: related: parse committish like format-patch

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 contrib/related/git-related| 15 +++
 contrib/related/test-related.t | 10 ++
 2 files changed, 25 insertions(+)

diff --git a/contrib/related/git-related b/contrib/related/git-related
index 4f78304..80e1f17 100755
--- a/contrib/related/git-related
+++ b/contrib/related/git-related
@@ -108,6 +108,21 @@ class Commits
   end
 
   def from_rev_args(args)
+revs = []
+
+File.popen(%w[git rev-parse --revs-only --default HEAD --symbolic] + 
args).each do |rev|
+  revs << rev.chomp
+end
+
+case revs.size
+when 1
+  r = revs[0]
+  r = '^' + r if r[0] != '-'
+  args = [ r, 'HEAD' ]
+else
+  args = revs
+end
+
 File.popen(%w[git rev-list --reverse] + args) do |p|
   p.each do |e|
 id = e.chomp
diff --git a/contrib/related/test-related.t b/contrib/related/test-related.t
index b623d69..39b4fe9 100755
--- a/contrib/related/test-related.t
+++ b/contrib/related/test-related.t
@@ -74,4 +74,14 @@ test_expect_success "from committish" "
test_cmp expected actual
 "
 
+test_expect_success "from single rev committish" "
+   git related -1 master | sort > actual &&
+   cat > expected <<-EOF &&
+   John Doe 
+   John Poppins 
+   Jon Stewart 
+   EOF
+   test_cmp expected actual
+"
+
 test_done
-- 
1.8.4-fc

--
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 v10 04/15] contrib: related: add option to parse from committish

2013-10-12 Thread Felipe Contreras
For example master..feature-a.

Signed-off-by: Felipe Contreras 
---
 contrib/related/git-related| 57 +++---
 contrib/related/test-related.t | 10 
 2 files changed, 53 insertions(+), 14 deletions(-)

diff --git a/contrib/related/git-related b/contrib/related/git-related
index 7e79d78..4f78304 100755
--- a/contrib/related/git-related
+++ b/contrib/related/git-related
@@ -1,10 +1,12 @@
 #!/usr/bin/env ruby
 
 # This script finds people that might be interested in a patch
-# usage: git related 
+# usage: git related 
 
 $since = '5-years-ago'
 $min_percent = 10
+$files = []
+$rev_args = []
 
 class Commit
 
@@ -82,21 +84,36 @@ class Commits
 end
   end
 
-  def from_patches(files)
+  def scan_patch(f, id = nil)
 source = nil
+f.each do |line|
+  case line
+  when /^From (\h+) (.+)$/
+id = $1
+@main_commits[id] = true
+  when /^---\s+(\S+)/
+source = $1 != '/dev/null' ? $1[2..-1] : nil
+  when /^@@ -(\d+)(?:,(\d+))?/
+get_blame(source, $1, $2, id) if source and id
+  end
+end
+  end
+
+  def from_patches(files)
 files.each do |file|
-  from = nil
   File.open(file) do |f|
-f.each do |line|
-  case line
-  when /^From (\h+) (.+)$/
-from = $1
-@main_commits[from] = true
-  when /^---\s+(\S+)/
-source = $1 != '/dev/null' ? $1[2..-1] : nil
-  when /^@@ -(\d+)(?:,(\d+))?/
-get_blame(source, $1, $2, from) if source and from
-  end
+scan_patch(f)
+  end
+end
+  end
+
+  def from_rev_args(args)
+File.popen(%w[git rev-list --reverse] + args) do |p|
+  p.each do |e|
+id = e.chomp
+@main_commits[id] = true
+File.popen(%w[git show -C --oneline] + [id]) do |p|
+  scan_patch(p, id)
 end
   end
 end
@@ -104,8 +121,20 @@ class Commits
 
 end
 
+ARGV.each do |e|
+  if File.exists?(e)
+$files << e
+  else
+$rev_args << e
+  end
+end
+
 commits = Commits.new
-commits.from_patches(ARGV)
+if $files.empty?
+  commits.from_rev_args($rev_args)
+else
+  commits.from_patches($files)
+end
 commits.import
 
 count_per_person = Hash.new(0)
diff --git a/contrib/related/test-related.t b/contrib/related/test-related.t
index 8102b3c..b623d69 100755
--- a/contrib/related/test-related.t
+++ b/contrib/related/test-related.t
@@ -64,4 +64,14 @@ test_expect_success "multiple patches" "
test_cmp expected actual
 "
 
+test_expect_success "from committish" "
+   git related -1 master | sort > actual &&
+   cat > expected <<-EOF &&
+   John Doe 
+   John Poppins 
+   Jon Stewart 
+   EOF
+   test_cmp expected actual
+"
+
 test_done
-- 
1.8.4-fc

--
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 try2 03/14] diff: document --staged

2013-10-12 Thread Felipe Contreras
Synonym for --cached.

Signed-off-by: Felipe Contreras 
---
 Documentation/git-diff.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt
index 78d6d50..646e5cd 100644
--- a/Documentation/git-diff.txt
+++ b/Documentation/git-diff.txt
@@ -10,7 +10,7 @@ SYNOPSIS
 
 [verse]
 'git diff' [options] [] [--] [...]
-'git diff' [options] --cached [] [--] [...]
+'git diff' [options] [--cached|--staged] [] [--] [...]
 'git diff' [options]   [--] [...]
 'git diff' [options]  
 'git diff' [options] [--no-index] [--]  
@@ -33,7 +33,7 @@ If exactly two paths are given and at least one points outside
 the current repository, 'git diff' will compare the two files /
 directories. This behavior can be forced by --no-index.
 
-'git diff' [--options] --cached [] [--] [...]::
+'git diff' [--options] [--cached|--staged] [] [--] [...]::
 
This form is to view the changes you staged for the next
commit relative to the named .  Typically you
-- 
1.8.4-fc

--
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 v10 11/15] contrib: related: allow usage on other directories

2013-10-12 Thread Felipe Contreras
Not just the root one (of the project).

Signed-off-by: Felipe Contreras 
---
 contrib/related/git-related | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/contrib/related/git-related b/contrib/related/git-related
index 3399307..f15e4e7 100755
--- a/contrib/related/git-related
+++ b/contrib/related/git-related
@@ -8,6 +8,10 @@ $min_percent = 10
 $files = []
 $rev_args = []
 
+git_dir = %x[git rev-parse --git-dir].chomp
+$base_dir = File.dirname(git_dir)
+$cur_dir = Dir.pwd
+
 KNOWN_ROLES = {
   'Signed-off-by' => :signer,
   'Reviewed-by' => :reviewer,
@@ -130,6 +134,7 @@ class Commits
   def get_blame(source, start, len, from)
 return if len == 0
 len ||= 1
+Dir.chdir($base_dir)
 File.popen(['git', 'blame', '--incremental', '-C', '-C',
'-L', '%u,+%u' % [start, len],
'--since', $since, from + '^',
@@ -141,6 +146,7 @@ class Commits
 end
   end
 end
+Dir.chdir($cur_dir)
   end
 
   def scan_patch(f, id = nil)
-- 
1.8.4-fc

--
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 04/20] fetch: add missing documentation

2013-10-12 Thread Felipe Contreras
There's no mention of the 'origin' default, or the fact that the
upstream tracking branch remote is used.

Signed-off-by: Felipe Contreras 
---
 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  is given and
 there is a remotes. entry in the configuration file.
 (See linkgit:git-config[1]).
 
+When no remote is specified, by the default the `origin` remote will be used,
+unless there's an upstream branch configured for the current branch.
+
 OPTIONS
 ---
 include::fetch-options.txt[]
-- 
1.8.4-fc

--
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 v10 10/15] contrib: related: group persons with same email

2013-10-12 Thread Felipe Contreras
Suggested-by: Duy Nguyen 
Signed-off-by: Felipe Contreras 
---
 contrib/related/git-related|  2 +-
 contrib/related/test-related.t | 12 
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/contrib/related/git-related b/contrib/related/git-related
index f94f5f4..3399307 100755
--- a/contrib/related/git-related
+++ b/contrib/related/git-related
@@ -56,7 +56,7 @@ class Persons
   end
 
   def self.get(name, email)
-id = [name, email]
+id = email.downcase
 person = @@index[id]
 if not person
   person = @@index[id] = Person.new(name, email)
diff --git a/contrib/related/test-related.t b/contrib/related/test-related.t
index 9da2693..a19ad32 100755
--- a/contrib/related/test-related.t
+++ b/contrib/related/test-related.t
@@ -44,8 +44,7 @@ test_expect_success "others" "
git format-patch --stdout -1 master > patch &&
git related patch | sort > actual &&
cat > expected <<-EOF &&
-   John Doe  (author: 33%)
-   John Poppins  (author: 33%)
+   John Poppins  (author: 66%)
Jon Stewart  (reviewer: 33%, author: 33%)
EOF
test_cmp expected actual
@@ -56,8 +55,7 @@ test_expect_success "multiple patches" "
git format-patch --stdout -1 master^ > patch2 &&
git related patch1 patch2 | sort > actual &&
cat > expected <<-EOF &&
-   John Doe  (author: 25%)
-   John Poppins  (author: 25%)
+   John Poppins  (author: 50%)
Jon Stewart  (reviewer: 25%, author: 25%)
Pablo Escobar  (author: 25%)
EOF
@@ -67,8 +65,7 @@ test_expect_success "multiple patches" "
 test_expect_success "from committish" "
git related -1 master | sort > actual &&
cat > expected <<-EOF &&
-   John Doe  (author: 33%)
-   John Poppins  (author: 33%)
+   John Poppins  (author: 66%)
Jon Stewart  (reviewer: 33%, author: 33%)
EOF
test_cmp expected actual
@@ -77,8 +74,7 @@ test_expect_success "from committish" "
 test_expect_success "from single rev committish" "
git related -1 master | sort > actual &&
cat > expected <<-EOF &&
-   John Doe  (author: 33%)
-   John Poppins  (author: 33%)
+   John Poppins  (author: 66%)
Jon Stewart  (reviewer: 33%, author: 33%)
EOF
test_cmp expected actual
-- 
1.8.4-fc

--
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 v10 00/15] New git-related helper

2013-10-12 Thread Felipe Contreras
This tool finds people that might be interested in a patch, by going
back through the history for each single hunk modified, and finding
people that reviewed, acknowledged, signed, or authored the code the
patch is modifying.

It does this by running `git blame` incrementally on each hunk, and
then parsing the commit message. After gathering all the relevant
people, it groups them to show what exactly was their role when the
participated in the development of the relevant commit, and on how
many relevant commits they participated. They are only displayed if
they pass a minimum threshold of participation.

For example:

  % git related master..fc/transport/improv
  Junio C Hamano  (signer: 90%, author: 5%)
  Felipe Contreras  (author: 25%, reviewer: 2%)
  Sverre Rabbelier  (author: 17%, acker: 2%, signer: 7%)
  Jeff King  (acker: 17%, author: 10%)
  Shawn O. Pearce  (author: 5%, signer: 2%, cced: 2%)
  Elijah Newren  (author: 10%)

In addition, it has an option to output the list of commits, instead
of the contributors, which allows you to easily find out the previous
changes to the lines your patches modify.

  % git related -c master..fc/transport/improv
  99d9ec0 Merge branch 'fc/transport-helper-no-refspec'
  67c9c78 transport-helper: barf when user tries old:new
  0460ed2 documentation: trivial style cleanups
  126aac5 transport-helper: fix remote helper namespace regression
  21610d8 transport-helper: clarify pushing without refspecs
  a93b4a0 transport-helper: warn when refspec is not used
  664059f transport-helper: update remote helper namespace
  c4458ec fast-export: Allow pruned-references in mark file
  ...

Moreover, when sending patches for review, you can configure `git
send-email` to use `git related` to find relevant people that should
be Cc'ed:

  % git send-email --cc-cmd='git related' *.patch

It has way many more features than git-contacts which is a rewrite in
Perl of this script, but only the initial bare minimum stage.

I've also added tests, and this is how git-contacts fares in comparison:

--- expected 2013-10-10 21:13:45.938291298 +
+++ actual 2013-10-10 21:13:45.937291298 +
@@ -1,2 +1,2 @@
-Jon Stewart  (author: 50%)
-Pablo Escobar  (author: 50%)
+Jon Stewart 
+Pablo Escobar 
not ok 1 - basic

git-contacts doesn't show the amount of involvement, but that's easy to fix.

--- expected 2013-10-10 21:13:45.975291299 +
+++ actual 2013-10-10 21:13:45.974291299 +
@@ -1,2 +1,3 @@
-John Poppins  (author: 66%)
-Jon Stewart  (reviewer: 33%, author: 33%)
+John Doe 
+John Poppins 
+Jon Stewart 
not ok 2 - others

git-contacts doesn't show the kind of involvement (reviewer, author)
nor does it group people by their email address.

(skip other failures)

expecting success:
git related -craw -1 master | git log --format='%s' --no-walk --stdin
> actual &&
cat > expected <<-EOF &&
four
three
one
EOF
test_cmp expected actual

not ok 7 - commits

Also, it doesn't have the option to show the commits themselves, which
is useful to investigate the diffs. This feature alone is what makes
the make "git-contacts" not appropriate, because if this feature is
implemented, 'git contacts --commits' wouldn't have anything to do
with "contacts".

For that matter it doesn't support any options at all (e.g.
--min-percent, --since), and doesn't have a usage helper (--help).

Changes since v9:

diff --git a/contrib/related/Makefile b/contrib/related/Makefile
new file mode 100644
index 000..1224fce
--- /dev/null
+++ b/contrib/related/Makefile
@@ -0,0 +1,17 @@
+TESTS := $(wildcard test-*.t)
+
+export T := $(addprefix $(CURDIR)/,$(TESTS))
+export MAKE := $(MAKE) -e
+export PATH := $(CURDIR):$(PATH)
+export TEST_LINT := test-lint-executable test-lint-shell-syntax
+export TEST_DIRECTORY := $(CURDIR)/../../t
+
+all:
+
+test:
+   $(MAKE) -C ../../t $@
+
+$(TESTS): all
+   $(MAKE) -C ../../t $(CURDIR)/$@
+
+.PHONY: all test $(TESTS)
diff --git a/contrib/related/README b/contrib/related/README
new file mode 100644
index 000..26188ca
--- /dev/null
+++ b/contrib/related/README
@@ -0,0 +1,65 @@
+= git-related =
+
+This tool finds people that might be interested in a patch, by going
+back through the history for each single hunk modified, and finding
+people that reviewed, acknowledged, signed, or authored the code the
+patch is modifying.
+
+It does this by running `git blame` incrementally on each hunk, and then
+parsing the commit message. After gathering all the relevant people, it
+groups them to show what exactly was their role when the participated in
+the development of the relevant commit, and on how many relevant commits
+they participated. They are only displayed if they pass a minimum
+threshold of participation.
+
+For example:
+
+
+% git related master..fc/transport/improv
+Junio C Hamano  (signer: 90%, author: 5%)
+Felipe Contreras  (author: 25%, reviewer: 2%)
+Sverre Rabbelier  (author: 17%, acker: 2%, signer: 7%)
+Jeff King  (acker: 17%, author: 10%)
+Shawn O. Pearce 

[PATCH 16/20] revision: trivial style fixes

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 revision.c | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/revision.c b/revision.c
index 0173e01..4049867 100644
--- a/revision.c
+++ b/revision.c
@@ -1503,7 +1503,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++);
}
 }
@@ -1515,7 +1515,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);
}
 }
@@ -2118,7 +2118,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);
@@ -2971,7 +2971,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)
@@ -2986,9 +2986,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) {
/*
@@ -3034,9 +3033,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-fc

--
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/20] alias: trivial style fix

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 alias.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/alias.c b/alias.c
index eb9f08b..9938f03 100644
--- a/alias.c
+++ b/alias.c
@@ -5,7 +5,7 @@ static char *alias_val;
 
 static int alias_lookup_cb(const char *k, const char *v, void *cb)
 {
-   if (!prefixcmp(k, "alias.") && !strcmp(k+6, alias_key)) {
+   if (!prefixcmp(k, "alias.") && !strcmp(k + 6, alias_key)) {
if (!v)
return config_error_nonbool(k);
alias_val = xstrdup(v);
@@ -34,7 +34,7 @@ int split_cmdline(char *cmdline, const char ***argv)
int src, dst, count = 0, size = 16;
char quoted = 0;
 
-   *argv = xmalloc(sizeof(char *) * size);
+   *argv = xmalloc(sizeof(**argv) * size);
 
/* split alias_string */
(*argv)[count++] = cmdline;
@@ -45,7 +45,7 @@ int split_cmdline(char *cmdline, const char ***argv)
while (cmdline[++src]
&& isspace(cmdline[src]))
; /* skip */
-   ALLOC_GROW(*argv, count+1, size);
+   ALLOC_GROW(*argv, count + 1, size);
(*argv)[count++] = cmdline + dst;
} else if (!quoted && (c == '\'' || c == '"')) {
quoted = c;
@@ -76,12 +76,13 @@ int split_cmdline(char *cmdline, const char ***argv)
return -SPLIT_CMDLINE_UNCLOSED_QUOTE;
}
 
-   ALLOC_GROW(*argv, count+1, size);
+   ALLOC_GROW(*argv, count + 1, size);
(*argv)[count] = NULL;
 
return count;
 }
 
-const char *split_cmdline_strerror(int split_cmdline_errno) {
-   return split_cmdline_errors[-split_cmdline_errno-1];
+const char *split_cmdline_strerror(int split_cmdline_errno)
+{
+   return split_cmdline_errors[-split_cmdline_errno - 1];
 }
-- 
1.8.4-fc

--
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 v4 1/2] version-gen: cleanup

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

Signed-off-by: Felipe Contreras 
---
 GIT-VERSION-GEN | 36 
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index 06026ea..e96538d 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -6,22 +6,29 @@ DEF_VER=v1.8.4
 LF='
 '
 
-# First see if there is a version file (included in release tarballs),
-# then try git-describe, then default.
-if test -f version
-then
-   VN=$(cat version) || VN="$DEF_VER"
-elif test -d ${GIT_DIR:-.git} -o -f .git &&
-   VN=$(git describe --match "v[0-9]*" --abbrev=7 HEAD 2>/dev/null) &&
+describe () {
+   VN=$(git describe --match "v[0-9]*" --abbrev=7 HEAD 2>/dev/null) || 
return 1
case "$VN" in
-   *$LF*) (exit 1) ;;
+   *$LF*)
+   return 1
+   ;;
v[0-9]*)
git update-index -q --refresh
test -z "$(git diff-index --name-only HEAD --)" ||
-   VN="$VN-dirty" ;;
+   VN="$VN-dirty"
+   return 0
+   ;;
esac
+}
+
+# First see if there is a version file (included in release tarballs),
+# then try 'git describe', then default.
+if test -f version
+then
+   VN=$(cat version) || VN="$DEF_VER"
+elif test -d ${GIT_DIR:-.git} -o -f .git && describe
 then
-   VN=$(echo "$VN" | sed -e 's/-/./g');
+   VN=$(echo "$VN" | sed -e 's/-/./g')
 else
VN="$DEF_VER"
 fi
@@ -34,9 +41,6 @@ then
 else
VC=unset
 fi
-test "$VN" = "$VC" || {
-   echo >&2 "GIT_VERSION = $VN"
-   echo "GIT_VERSION = $VN" >$GVF
-}
-
-
+test "$VN" = "$VC" && exit
+echo >&2 "GIT_VERSION = $VN"
+echo "GIT_VERSION = $VN" >$GVF
-- 
1.8.4-fc

--
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 v4 2/2] version-gen: fix versions

2013-10-12 Thread Felipe Contreras
Virtually all packaging guidelines would prefer 1.8.4~rc1, over
1.8.4.rc1 or 1.8.4-rc1, so it makes sense to use that instead.

In particular, the only packaging we provide, git.spec, generates a
wrong version, because git-1.8.4 < git-1.8.4.rc1, changing to ~rc1 fixes
the problem as it's considered newer.

The same happens in dpkg.

Signed-off-by: Felipe Contreras 
---
 GIT-VERSION-GEN | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index e96538d..c04c4de 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -28,7 +28,7 @@ then
VN=$(cat version) || VN="$DEF_VER"
 elif test -d ${GIT_DIR:-.git} -o -f .git && describe
 then
-   VN=$(echo "$VN" | sed -e 's/-/./g')
+   VN=$(echo "$VN" | sed -e 's/-/~/g')
 else
VN="$DEF_VER"
 fi
-- 
1.8.4-fc

--
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 v3 06/10] transport-helper: add support for old:new refspec

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

Signed-off-by: Felipe Contreras 
---
 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 8c4c539..8e2dd9f 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 46b3e57..cffeb9a 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -809,7 +809,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)
@@ -847,8 +847,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);
}
}
@@ -856,6 +861,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);
-- 
1.8.4-fc

--
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 try2] fetch: add new fetch.default configuration

2013-10-12 Thread Felipe Contreras
When the user has an upstream branch configured to track a remote
tracking branch:

  % git checkout --set-upstream-to github/master

Doing a 'git fetch' without any arguments would try to fetch 'github',
because it's configured as current branch's remote
(branch..remote).

However, if we do something slightly different:

  % git checkout --set-upstream-to master

Doing a 'git fetch' without any arguments would try to fetch the remote
'.', for the same reason.

But, unlike the in the first instance, the second command would not
update any remote tracking branch, in fact, it would not update any
branch at all. The only effect is that it would update FETCH_HEAD.

FETCH_HEAD is a special symbol that is used to store the result of a
fetch. It can be used by other commands of git, specially 'git merge'.

It is however, barely mentioned in the documentation, and can be
considered a plumbing concept at best, that few Git users would benefit
from using, and indeed, quite likely very few use it, or are even aware
of it.

So when the user is presented with a message like this:

  % git fetch
  From .
   * branchmaster -> FETCH_HEAD

The vast majority of them would have absolutely no idea what's going on.
Many of them would probably just shrug, and manually specify the remote
the want to fetch from, which is 'origin' in many cases, *if* they
manage to notice the '.' at all.

If the user has say, twenty branches, ten with a local upstream
(branch..remote = '.'), and ten without an upstream. The user
might get used to typing 'git fetch' and expect Git to fetch from
'origin' which would happen 50% of the time, but the other 50%, the user
would be forced to specify the remote.

This inconsistency would be simply one more to join the list of
incomprehensible quirks the user has to put up when using Git, so quite
likely he simply gets used to it, only to complain later in forums or
social media, outside of the dwelling distance of the typical Git
developer.

But we can do better.

We can add a new 'fetch.default' configuration variable (one more to
join the many necessary to force Git to behave in sane manner), so the
user can specify what she wants to be performed when the remote is not
specified in the 'git fetch' command.

This configuration would probably be welcomed by 99% of the user
population, who have no clue what FETCH_HEAD is, and do set local
upstream branches, only to find out weird inconsistent behavior
depending on which branch they happen to be sitting at.

We add documentation and testing as expected, and also introduce other
changes necessary to make the configuration enter into effect when it's
needed.

The default (FETCH_DEFAULT_UNSPECIFIED), allows the current behavior to
be unmodified, so remote_get(NULL) is called, and the current rules to
determine the default branch remain.

The new option "simple" allows Git to always fetch from "origin", which
is what most users would expect, and it's 100% consistent.

Alternatively, the user can manually specify the current behavior with
"current" (alluding to the current branch), so that the behavior changes
depending on which branch the user happens to be sitting at. This would
allow the user to retain this behavior, if she so wishes,
in case Git developers regain their senses and set a default that most
users would appreciate ("simple").

If the user wants, for whatever strange reason swimming in his/her head,
he can still fetch from a local ('.') remote (even stating that as an
English sentence doesn't make any sense).

  % git fetch .
  From .
   * branchmaster -> FETCH_HEAD

And to any number of weird hacks with FETCH_HEAD.

The average user lucky enough to find the 'fetch.default' configuration,
however, would never have to enter the word of "local remote"
strangeness, and would remain comfortably in the place where locals are
locals, and remotes are remotes, and 'git fetch' is always consistent,
and always does something useful.

Signed-off-by: Felipe Contreras 
---
 Documentation/config.txt|  9 +
 Documentation/git-fetch.txt |  4 
 builtin/fetch.c | 10 +-
 cache.h |  7 +++
 config.c| 21 +
 environment.c   |  1 +
 t/t5513-fetch-track.sh  | 43 +++
 7 files changed, 94 insertions(+), 1 deletion(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index ec57a15..fdf3c77 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1892,6 +1892,15 @@ to `simple`.
 
 --
 
+fetch.default::
+   Defines the action `git fetch` should take if no remote is specified
+   on the command line. Possible values are:
++
+--
+* `current` - fetch from the upstream of the current branch.
+* `simple` - always fetch from `origin`.
+--
+
 rebase.stat::
Whether to show a diffstat of what changed upstream since the last
rebase. False by default

[PATCH v10 15/15] contrib: related: add README

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 contrib/related/README | 65 ++
 1 file changed, 65 insertions(+)
 create mode 100644 contrib/related/README

diff --git a/contrib/related/README b/contrib/related/README
new file mode 100644
index 000..26188ca
--- /dev/null
+++ b/contrib/related/README
@@ -0,0 +1,65 @@
+= git-related =
+
+This tool finds people that might be interested in a patch, by going
+back through the history for each single hunk modified, and finding
+people that reviewed, acknowledged, signed, or authored the code the
+patch is modifying.
+
+It does this by running `git blame` incrementally on each hunk, and then
+parsing the commit message. After gathering all the relevant people, it
+groups them to show what exactly was their role when the participated in
+the development of the relevant commit, and on how many relevant commits
+they participated. They are only displayed if they pass a minimum
+threshold of participation.
+
+For example:
+
+
+% git related master..fc/transport/improv
+Junio C Hamano  (signer: 90%, author: 5%)
+Felipe Contreras  (author: 25%, reviewer: 2%)
+Sverre Rabbelier  (author: 17%, acker: 2%, signer: 7%)
+Jeff King  (acker: 17%, author: 10%)
+Shawn O. Pearce  (author: 5%, signer: 2%, cced: 2%)
+Elijah Newren  (author: 10%)
+
+
+In addition, it has an option to output the list of commits, instead of the
+contributors, which allows you to easily find out the previous changes to the
+lines your patches modify.
+
+
+% git related -c master..fc/transport/improv
+99d9ec0 Merge branch 'fc/transport-helper-no-refspec'
+67c9c78 transport-helper: barf when user tries old:new
+0460ed2 documentation: trivial style cleanups
+126aac5 transport-helper: fix remote helper namespace regression
+21610d8 transport-helper: clarify pushing without refspecs
+a93b4a0 transport-helper: warn when refspec is not used
+664059f transport-helper: update remote helper namespace
+c4458ec fast-export: Allow pruned-references in mark file
+...
+
+
+Moreover, when sending patches for review, you can configure `git send-email`
+to use `git related` to find relevant people that should be Cc'ed:
+
+
+% git send-email --cc-cmd='git related' *.patch
+
+
+== Installation ==
+
+To use this script, simply put `git-related` in your `$PATH` and make sure it
+has executable permissions:
+
+
+wget https://raw.github.com/felipec/git-related/master/git-related -O 
~/bin/git-related
+chmod +x ~/bin/git-related
+
+
+And make sure `~/bin` is in your `$PATH`:
+
+
+export PATH="$HOME/bin:$PATH"
+
-- 
1.8.4-fc

--
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 try2 1/8] branch: trivial cleanup

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

Signed-off-by: Felipe Contreras 
---
 builtin/branch.c | 19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/builtin/branch.c b/builtin/branch.c
index 0836890..ac17b18 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -425,16 +425,15 @@ static void fill_tracking_info(struct strbuf *stat, const 
char *branch_name,
struct strbuf fancy = STRBUF_INIT;
 
if (!stat_tracking_info(branch, &ours, &theirs)) {
-   if (branch && branch->merge && branch->merge[0]->dst &&
-   show_upstream_ref) {
-   ref = shorten_unambiguous_ref(branch->merge[0]->dst, 0);
-   if (want_color(branch_use_color))
-   strbuf_addf(stat, "[%s%s%s] ",
-   
branch_get_color(BRANCH_COLOR_UPSTREAM),
-   ref, 
branch_get_color(BRANCH_COLOR_RESET));
-   else
-   strbuf_addf(stat, "[%s] ", ref);
-   }
+   if (!branch || !branch->merge || !branch->merge[0]->dst || 
!show_upstream_ref)
+   return;
+   ref = shorten_unambiguous_ref(branch->merge[0]->dst, 0);
+   if (want_color(branch_use_color))
+   strbuf_addf(stat, "[%s%s%s] ",
+   branch_get_color(BRANCH_COLOR_UPSTREAM),
+   ref, 
branch_get_color(BRANCH_COLOR_RESET));
+   else
+   strbuf_addf(stat, "[%s] ", ref);
return;
}
 
-- 
1.8.4-fc

--
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 v3 04/10] fast-export: improve argument parsing

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

Signed-off-by: Felipe Contreras 
---
 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 8e19058..91114f4 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -694,8 +694,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-fc

--
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 try2 6/8] t: branch add publish branch tests

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 t/t3200-branch.sh | 76 +++
 1 file changed, 76 insertions(+)

diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 44ec6a4..cd0b8e9 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -870,4 +870,80 @@ test_expect_success '--merged catches invalid object 
names' '
test_must_fail git branch --merged 

 '
 
+test_expect_success '--set-publish-to fails on multiple branches' '
+   test_must_fail git branch --set-publish-to master a b c
+'
+
+test_expect_success '--set-publish-to fails on detached HEAD' '
+   test_when_finished "git checkout master" &&
+   git checkout master^{} &&
+   test_must_fail git branch --set-publish-to master
+'
+
+test_expect_success '--set-publish-to fails on a missing dst branch' '
+   test_must_fail git branch --set-publish-to master does-not-exist
+'
+
+test_expect_success '--set-publish-to fails on a missing src branch' '
+   test_must_fail git branch --set-publish-to does-not-exist master
+'
+
+test_expect_success '--set-publish-to fails on a non-ref' '
+   test_must_fail git branch --set-publish-to HEAD^{}
+'
+
+test_expect_success 'use --set-publish-to modify HEAD' '
+   git checkout master &&
+   test_config branch.master.pushremote foo &&
+   test_config branch.master.push foo &&
+   git branch -f test &&
+   git branch --set-publish-to test &&
+   test "$(git config branch.master.pushremote)" = "." &&
+   test "$(git config branch.master.push)" = "refs/heads/test"
+'
+
+test_expect_success 'use --set-publish-to modify a particular branch' '
+   git branch -f test &&
+   git branch -f test2 &&
+   git branch --set-publish-to test2 test &&
+   test "$(git config branch.test.pushremote)" = "." &&
+   test "$(git config branch.test.push)" = "refs/heads/test2"
+'
+
+test_expect_success '--unset-publish should fail if given a non-existent 
branch' '
+   test_must_fail git branch --unset-publish i-dont-exist
+'
+
+test_expect_success 'test --unset-publish on HEAD' '
+   git checkout master &&
+   git branch -f test &&
+   test_config branch.master.pushremote foo &&
+   test_config branch.master.push foo &&
+   git branch --set-publish-to test &&
+   git branch --unset-publish &&
+   test_must_fail git config branch.master.pushremote &&
+   test_must_fail git config branch.master.push &&
+   # fail for a branch without publish set
+   test_must_fail git branch --unset-publish
+'
+
+test_expect_success '--unset-publish should fail on multiple branches' '
+   test_must_fail git branch --unset-publish a b c
+'
+
+test_expect_success '--unset-publish should fail on detached HEAD' '
+   test_when_finished "git checkout -" &&
+   git checkout HEAD^{} &&
+   test_must_fail git branch --unset-publish
+'
+
+test_expect_success 'test --unset-publish on a particular branch' '
+   git branch -f test &&
+   git branch -f test2 &&
+   git branch --set-publish-to test2 test &&
+   git branch --unset-publish test &&
+   test_must_fail git config branch.test2.pushremote &&
+   test_must_fail git config branch.test2.push
+'
+
 test_done
-- 
1.8.4-fc

--
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 try2 7/8] push: add --set-publish option

2013-10-12 Thread Felipe Contreras
To setup publish tracking branch, like 'git branch --set-publish'.

Signed-off-by: Felipe Contreras 
---
 Documentation/git-push.txt |  9 +-
 builtin/push.c |  2 ++
 t/t5529-push-publish.sh| 70 ++
 transport.c| 28 +--
 transport.h|  1 +
 5 files changed, 100 insertions(+), 10 deletions(-)
 create mode 100755 t/t5529-push-publish.sh

diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index f7dfe48..6f3885d 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -10,7 +10,8 @@ SYNOPSIS
 
 [verse]
 'git push' [--all | --mirror | --tags] [--follow-tags] [-n | --dry-run] 
[--receive-pack=]
-  [--repo=] [-f | --force] [--prune] [-v | --verbose] [-u 
| --set-upstream]
+  [--repo=] [-f | --force] [--prune] [-v | --verbose]
+  [-u | --set-upstream] [-p | --set-publish]
   [--no-verify] [ [...]]
 
 DESCRIPTION
@@ -171,6 +172,12 @@ useful if you write an alias or script around 'git push'.
linkgit:git-pull[1] and other commands. For more information,
see 'branch..merge' in linkgit:git-config[1].
 
+-p::
+--set-publish::
+   For every branch that is up to date or successfully pushed, add
+   publish branch tracking reference, used by argument-less
+   linkgit:git-pull[1] and other commands.
+
 --[no-]thin::
These options are passed to linkgit:git-send-pack[1]. A thin transfer
significantly reduces the amount of sent data when the sender and
diff --git a/builtin/push.c b/builtin/push.c
index f2deddf..1c184b3 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -473,6 +473,8 @@ int cmd_push(int argc, const char **argv, const char 
*prefix)
OPT_STRING( 0 , "exec", &receivepack, "receive-pack", 
N_("receive pack program")),
OPT_BIT('u', "set-upstream", &flags, N_("set upstream for git 
pull/status"),
TRANSPORT_PUSH_SET_UPSTREAM),
+   OPT_BIT('p', "set-publish", &flags, N_("set publish for git 
pull/status"),
+   TRANSPORT_PUSH_SET_PUBLISH),
OPT_BOOL(0, "progress", &progress, N_("force progress 
reporting")),
OPT_BIT(0, "prune", &flags, N_("prune locally removed refs"),
TRANSPORT_PUSH_PRUNE),
diff --git a/t/t5529-push-publish.sh b/t/t5529-push-publish.sh
new file mode 100755
index 000..2037026
--- /dev/null
+++ b/t/t5529-push-publish.sh
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+test_description='push with --set-publish'
+
+. ./test-lib.sh
+
+test_expect_success 'setup bare parent' '
+   git init --bare parent &&
+   git remote add publish parent
+'
+
+test_expect_success 'setup local commit' '
+   echo content >file &&
+   git add file &&
+   git commit -m one
+'
+
+check_config() {
+   (echo $2; echo $3) >expect.$1
+   (git config branch.$1.pushremote
+git config branch.$1.push) >actual.$1
+   test_cmp expect.$1 actual.$1
+}
+
+test_expect_success 'push -p master:master' '
+   git push -p publish master:master &&
+   check_config master publish refs/heads/master
+'
+
+test_expect_success 'push -u master:other' '
+   git push -p publish master:other &&
+   check_config master publish refs/heads/other
+'
+
+test_expect_success 'push -p --dry-run master:otherX' '
+   git push -p --dry-run publish master:otherX &&
+   check_config master publish refs/heads/other
+'
+
+test_expect_success 'push -p master2:master2' '
+   git branch master2 &&
+   git push -p publish master2:master2 &&
+   check_config master2 publish refs/heads/master2
+'
+
+test_expect_success 'push -p master2:other2' '
+   git push -p publish master2:other2 &&
+   check_config master2 publish refs/heads/other2
+'
+
+test_expect_success 'push -p :master2' '
+   git push -p publish :master2 &&
+   check_config master2 publish refs/heads/other2
+'
+
+test_expect_success 'push -u --all' '
+   git branch all1 &&
+   git branch all2 &&
+   git push -p --all &&
+   check_config all1 publish refs/heads/all1 &&
+   check_config all2 publish refs/heads/all2
+'
+
+test_expect_success 'push -p HEAD' '
+   git checkout -b headbranch &&
+   git push -p publish HEAD &&
+   check_config headbranch publish refs/heads/headbranch
+'
+
+test_done
diff --git a/transport.c b/transport.c
index e15db98..d796732 100644
--- a/transport.c
+++ b/transport.c
@@ -140,8 +140,8 @@ static void insert_packed_refs(const char *packed_refs, 
struct ref **list)
}
 }
 
-static void set_upstreams(struct transport *transport, struct ref *refs,
-   int pretend)
+static void set_tracking(struct transport *transport, struct ref *refs,
+   int pretend, int publish)
 {
struct ref *ref;
for (ref = refs; ref; ref = ref->next) {
@@ -176,12 +176,18 @@ static void set_upstreams(struct transport

[PATCH 14/20] describe: trivial style fixes

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 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   (1u<<0)
+#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-fc

--
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 v10 02/15] contrib: related: add tests

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 contrib/related/Makefile   | 17 +
 contrib/related/test-related.t | 54 ++
 2 files changed, 71 insertions(+)
 create mode 100644 contrib/related/Makefile
 create mode 100755 contrib/related/test-related.t

diff --git a/contrib/related/Makefile b/contrib/related/Makefile
new file mode 100644
index 000..1224fce
--- /dev/null
+++ b/contrib/related/Makefile
@@ -0,0 +1,17 @@
+TESTS := $(wildcard test-*.t)
+
+export T := $(addprefix $(CURDIR)/,$(TESTS))
+export MAKE := $(MAKE) -e
+export PATH := $(CURDIR):$(PATH)
+export TEST_LINT := test-lint-executable test-lint-shell-syntax
+export TEST_DIRECTORY := $(CURDIR)/../../t
+
+all:
+
+test:
+   $(MAKE) -C ../../t $@
+
+$(TESTS): all
+   $(MAKE) -C ../../t $(CURDIR)/$@
+
+.PHONY: all test $(TESTS)
diff --git a/contrib/related/test-related.t b/contrib/related/test-related.t
new file mode 100755
index 000..b69684d
--- /dev/null
+++ b/contrib/related/test-related.t
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+test_description="Test git related"
+
+test -z "$TEST_DIRECTORY" && TEST_DIRECTORY="$PWD/../../t"
+. "$TEST_DIRECTORY"/test-lib.sh
+
+setup() {
+   git init &&
+   echo one > content &&
+   git add content &&
+   git commit -q -m one --author='Pablo Escobar ' &&
+   echo two >> content &&
+   git commit -q -a -m one --author='Jon Stewart ' &&
+   echo three >> content &&
+   git commit -q -a -m three --author='John Doe ' &&
+   echo four >> content &&
+   git branch basic &&
+   git commit -q -a -F - --author='John Poppins ' <<-EOF &&
+   four
+
+   Reviewed-by: Jon Stewart 
+   EOF
+   echo five >> content &&
+   git commit -q -a -m five --author='Mary Poppins '
+   git checkout -b next &&
+   echo six >> content &&
+   git commit -q -a -m six --author='Ocatio Paz '
+}
+
+setup
+
+test_expect_success "basic" "
+   git format-patch --stdout -1 basic > patch &&
+   git related patch | sort > actual &&
+   cat > expected <<-EOF &&
+   Jon Stewart 
+   Pablo Escobar 
+   EOF
+   test_cmp expected actual
+"
+
+test_expect_success "others" "
+   git format-patch --stdout -1 master > patch &&
+   git related patch | sort > actual &&
+   cat > expected <<-EOF &&
+   John Doe 
+   John Poppins 
+   Jon Stewart 
+   EOF
+   test_cmp expected actual
+"
+
+test_done
-- 
1.8.4-fc

--
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 v10 06/15] contrib: related: print the amount of involvement

2013-10-12 Thread Felipe Contreras
100% means the person was involved in all the commits, in one way or the
other.

Signed-off-by: Felipe Contreras 
---
 contrib/related/git-related|  2 +-
 contrib/related/test-related.t | 30 +++---
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/contrib/related/git-related b/contrib/related/git-related
index 80e1f17..ffce839 100755
--- a/contrib/related/git-related
+++ b/contrib/related/git-related
@@ -163,5 +163,5 @@ end
 count_per_person.each do |person, count|
   percent = count.to_f * 100 / commits.size
   next if percent < $min_percent
-  puts person
+  puts '%s (involved: %u%%)' % [person, percent]
 end
diff --git a/contrib/related/test-related.t b/contrib/related/test-related.t
index 39b4fe9..ec2680a 100755
--- a/contrib/related/test-related.t
+++ b/contrib/related/test-related.t
@@ -34,8 +34,8 @@ test_expect_success "basic" "
git format-patch --stdout -1 basic > patch &&
git related patch | sort > actual &&
cat > expected <<-EOF &&
-   Jon Stewart 
-   Pablo Escobar 
+   Jon Stewart  (involved: 50%)
+   Pablo Escobar  (involved: 50%)
EOF
test_cmp expected actual
 "
@@ -44,9 +44,9 @@ test_expect_success "others" "
git format-patch --stdout -1 master > patch &&
git related patch | sort > actual &&
cat > expected <<-EOF &&
-   John Doe 
-   John Poppins 
-   Jon Stewart 
+   John Doe  (involved: 33%)
+   John Poppins  (involved: 33%)
+   Jon Stewart  (involved: 66%)
EOF
test_cmp expected actual
 "
@@ -56,10 +56,10 @@ test_expect_success "multiple patches" "
git format-patch --stdout -1 master^ > patch2 &&
git related patch1 patch2 | sort > actual &&
cat > expected <<-EOF &&
-   John Doe 
-   John Poppins 
-   Jon Stewart 
-   Pablo Escobar 
+   John Doe  (involved: 25%)
+   John Poppins  (involved: 25%)
+   Jon Stewart  (involved: 50%)
+   Pablo Escobar  (involved: 25%)
EOF
test_cmp expected actual
 "
@@ -67,9 +67,9 @@ test_expect_success "multiple patches" "
 test_expect_success "from committish" "
git related -1 master | sort > actual &&
cat > expected <<-EOF &&
-   John Doe 
-   John Poppins 
-   Jon Stewart 
+   John Doe  (involved: 33%)
+   John Poppins  (involved: 33%)
+   Jon Stewart  (involved: 66%)
EOF
test_cmp expected actual
 "
@@ -77,9 +77,9 @@ test_expect_success "from committish" "
 test_expect_success "from single rev committish" "
git related -1 master | sort > actual &&
cat > expected <<-EOF &&
-   John Doe 
-   John Poppins 
-   Jon Stewart 
+   John Doe  (involved: 33%)
+   John Poppins  (involved: 33%)
+   Jon Stewart  (involved: 66%)
EOF
test_cmp expected actual
 "
-- 
1.8.4-fc

--
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/20] revision: add missing include

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

Signed-off-by: Felipe Contreras 
---
 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   (1u<<0)
 #define UNINTERESTING   (1u<<1)
-- 
1.8.4-fc

--
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 v4 0/2] Version fixes and cleanups

2013-10-12 Thread Felipe Contreras
Chances since v3:

diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index 19902e9..c04c4de 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -26,8 +26,10 @@ describe () {
 if test -f version
 then
VN=$(cat version) || VN="$DEF_VER"
-elif test ! -d ${GIT_DIR:-.git} -a ! -f .git || ! describe
+elif test -d ${GIT_DIR:-.git} -o -f .git && describe
 then
+   VN=$(echo "$VN" | sed -e 's/-/~/g')
+else
VN="$DEF_VER"
 fi
 
diff --git a/Makefile b/Makefile
index 7a8bee7..3588ca1 100644
--- a/Makefile
+++ b/Makefile
@@ -2426,7 +2426,7 @@ quick-install-html:
 ### Maintainer's dist rules
 
 git.spec: git.spec.in GIT-VERSION-FILE
-   sed -e 's/@@VERSION@@/$(subst -,~,$(GIT_VERSION))/g' < $< > $@+
+   sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@+
mv $@+ $@
 
 GIT_TARNAME = git-$(GIT_VERSION)

Felipe Contreras (2):
  version-gen: cleanup
  version-gen: fix versions

 GIT-VERSION-GEN | 36 
 1 file changed, 20 insertions(+), 16 deletions(-)

-- 
1.8.4-fc

--
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 try2 5/8] branch: allow configuring the publish branch

2013-10-12 Thread Felipe Contreras
Signed-off-by: Felipe Contreras 
---
 Documentation/git-branch.txt | 11 +
 branch.c | 43 ++
 branch.h |  2 ++
 builtin/branch.c | 56 
 4 files changed, 108 insertions(+), 4 deletions(-)

diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt
index b7cb625..1bf9b2a 100644
--- a/Documentation/git-branch.txt
+++ b/Documentation/git-branch.txt
@@ -14,7 +14,9 @@ SYNOPSIS
[(--merged | --no-merged | --contains) []] [...]
 'git branch' [--set-upstream | --track | --no-track] [-l] [-f]  
[]
 'git branch' (--set-upstream-to= | -u ) []
+'git branch' (--set-publish-to= | -p ) []
 'git branch' --unset-upstream []
+'git branch' --unset-publish []
 'git branch' (-m | -M) [] 
 'git branch' (-d | -D) [-r] ...
 'git branch' --edit-description []
@@ -189,6 +191,15 @@ start-point is either a local or remote-tracking branch.
Remove the upstream information for . If no branch
is specified it defaults to the current branch.
 
+-p ::
+--set-publish-to=::
+   Set up 's publish tracking information. If no
+is specified, then it defaults to the current branch.
+
+--unset-publish::
+   Remove the publish information for . If no branch
+   is specified it defaults to the current branch.
+
 --edit-description::
Open an editor and edit the text to explain what the branch is
for, to be used by various other commands (e.g. `request-pull`).
diff --git a/branch.c b/branch.c
index c5c6984..02495e3 100644
--- a/branch.c
+++ b/branch.c
@@ -144,6 +144,49 @@ static int setup_tracking(const char *new_ref, const char 
*orig_ref,
return 0;
 }
 
+void install_branch_publish(const char *name, const char *remote, const char 
*remote_ref)
+{
+   struct strbuf key = STRBUF_INIT;
+
+   if (!remote && !strcmp(name, remote_ref + 11) && !prefixcmp(remote_ref, 
"refs/heads")) {
+   warning(_("Not setting branch %s as its own publish branch."), 
name);
+   return;
+   }
+
+   strbuf_addf(&key, "branch.%s.pushremote", name);
+   git_config_set(key.buf, remote ? remote : ".");
+
+   strbuf_reset(&key);
+   strbuf_addf(&key, "branch.%s.push", name);
+   git_config_set(key.buf, remote_ref);
+
+   strbuf_release(&key);
+}
+
+int setup_publish(const char *name, const char *ref)
+{
+   struct tracking tracking;
+   const char *remote, *remote_ref;
+
+   memset(&tracking, 0, sizeof(tracking));
+   tracking.spec.dst = (char*)ref;
+   if (for_each_remote(find_tracked_branch, &tracking))
+   return 1;
+
+   if (tracking.matches > 1)
+   return error(_("Not tracking: ambiguous information for ref 
%s"),
+   ref);
+
+   remote = tracking.remote;
+   remote_ref = tracking.src ? tracking.src : ref;
+
+   install_branch_publish(name, remote, remote_ref);
+
+   free(tracking.src);
+
+   return 0;
+}
+
 struct branch_desc_cb {
const char *config_name;
const char *value;
diff --git a/branch.h b/branch.h
index 64173ab..c9b6aa9 100644
--- a/branch.h
+++ b/branch.h
@@ -51,5 +51,7 @@ extern void install_branch_config(int flag, const char 
*local, const char *origi
  * Read branch description
  */
 extern int read_branch_desc(struct strbuf *, const char *branch_name);
+extern int setup_publish(const char *name, const char *ref);
+extern void install_branch_publish(const char *name, const char *remote, const 
char *remote_ref);
 
 #endif
diff --git a/builtin/branch.c b/builtin/branch.c
index baa1d31..cf33e1c 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -778,8 +778,8 @@ int cmd_branch(int argc, const char **argv, const char 
*prefix)
int delete = 0, rename = 0, force_create = 0, list = 0;
int verbose = 0, abbrev = -1, detached = 0;
int reflog = 0, edit_description = 0;
-   int quiet = 0, unset_upstream = 0;
-   const char *new_upstream = NULL;
+   int quiet = 0, unset_upstream = 0, unset_publish = 0;
+   const char *new_upstream = NULL, *publish = NULL;
enum branch_track track;
int kinds = REF_LOCAL_BRANCH;
struct commit_list *with_commit = NULL;
@@ -794,7 +794,9 @@ int cmd_branch(int argc, const char **argv, const char 
*prefix)
OPT_SET_INT( 0, "set-upstream",  &track, N_("change upstream 
info"),
BRANCH_TRACK_OVERRIDE),
OPT_STRING('u', "set-upstream-to", &new_upstream, "upstream", 
"change the upstream info"),
+   OPT_STRING('p', "set-publish-to", &publish, "publish", "change 
the publish info"),
OPT_BOOLEAN(0, "unset-upstream", &unset_upstream, "Unset the 
upstream info"),
+   OPT_BOOLEAN(0, "unset-publish", &unset_publish, "Unset the 
publish info"),
OPT__COLOR(&branch_use_color, N_("use colored output")),

My patches

2013-10-12 Thread Felipe Contreras
Hi,

Clearly, a lot of my patches have not been reviewed properly, so even
though they are technically correct, and would benefit users, some have
specifically been requested by them, and at least one would
significantly improve Git's user interface... they are going nowhere.

Here is the summary, and you can also find a web version:
https://github.com/felipec/git/wiki/My-patches

Cheers.

=== branch: improve verbose option ===

People have commented that this is a good change, yet it's ignored.


Felipe Contreras (2):
  branch: trivial cleanup
  branch: reorganize verbose options


Link: https://github.com/felipec/git/commits/fc/branch/fast +
Patches: 
http://mid.gmane.org/1381561229-19947-1-git-send-email-felipe.contre...@gmail.com
 +

=== Reject non-ff pulls by default (v4) ===

The conclusion of the discussions is that this change is good, yet it doesn't 
move forward.


Felipe Contreras (7):
  pull: rename pull.rename to pull.mode
  pull: refactor $rebase variable into $mode
  pull: add --merge option
  pull: add merge-ff-only option
  pull: add warning on non-ff merges
  pull: cleanup documentation
  pull: add documentation about non-ff merges


Link: https://github.com/felipec/git/commits/fc/pull-merge-ff-only +
Patches: 
http://mid.gmane.org/1381561322-20059-1-git-send-email-felipe.contre...@gmail.com
 +

=== remote-helpers: test reorganization (v2) ===

People have requested both that the scripts are autogenerated, and that we
provide instructions how to install these for distributions, this fixes both,
and yet is not merged.


Felipe Contreras (5):
  remote-helpers: generate scripts
  build: fix installation of scripts
  remote-helpers: rename tests
  remote-helpers: allow direct test execution
  remote-helpers: add exec-path links


Link: https://github.com/felipec/git/commits/fc/remote/reorg +
Patches: 
http://mid.gmane.org/1381561465-20147-1-git-send-email-felipe.contre...@gmail.com
 +

=== build: add default aliases (v3) ===

All version control systems out there have default aliases, except Git.
Mercurial even allows overriding the main commands, like 'hg commit' so all the
arguments that use the override of default aliases causing discrepancies as a
reason to reject this change are void, since clearly Mercurial doesn't have
such problems.


Felipe Contreras (1):
  build: add default aliases


Link: https://github.com/felipec/git/commits/fc/default-aliases +
Patches: 
http://mid.gmane.org/1381561482-20208-1-git-send-email-felipe.contre...@gmail.com
 +

=== Add core.mode configuration (v3) ===

Not even a reply.


Felipe Contreras (1):
  Add core.mode configuration


Link: https://github.com/felipec/git/commits/fc/config-mode-next +
Patches: 
http://mid.gmane.org/1381561485-20252-1-git-send-email-felipe.contre...@gmail.com
 +

=== Officially start moving to the term 'staging area' ===

Everybody agrees this is the way to go, and yet Junio doesn't comment on the way
forward.


Felipe Contreras (14):
  Add proper 'stage' command
  stage: add edit command
  diff: document --staged
  grep: add --staged option
  rm: add --staged option
  stash: add --stage option to save
  stash: add --stage to pop and apply
  submodule: add --staged options
  apply: add --stage option
  apply: add --work, --no-work options
  completion: update --staged options
  reset: add --stage and --work options
  reset: allow --keep with --stage
  completion: update 'git reset' new stage options


Link: https://github.com/felipec/git/commits/fc/stage +
Patches: 
http://mid.gmane.org/1381561488-20294-1-git-send-email-felipe.contre...@gmail.com
 +

=== transport-helper: updates (v3) ===

People have requested --foce --dry-run and old:new support for remote helpers,
this introduces those options and it was rejected without any reason given.


Felipe Contreras (10):
  transport-helper: add 'force' to 'export' helpers
  transport-helper: fix extra lines
  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
  transport-helper: don't update refs in dry-run


Link: https://github.com/felipec/git/commits/fc/transport/improv +
Patches: 
http://mid.gmane.org/1381561533-20381-1-git-send-email-felipe.contre...@gmail.com
 +

=== Introduce publish tracking branch ===

This improves the support for triangular workflows, which even Junio accepted
is lacking, yet it didn't even receive comments.


Felipe Contreras (8):
  branch: trivial cleanup
  branch: reorganize verbose options
  push: trivial reorganization
  Add concept of 'publish' branch

Re: [PATCH 12/20] alias: trivial style fix

2013-10-12 Thread Stefan Beller
On 10/12/2013 09:07 AM, Felipe Contreras wrote:
> Signed-off-by: Felipe Contreras 
Not sure if it's worth by a newcomer. ;)

Reviewed-by:  Stefan Beller 

> ---
>  alias.c | 13 +++--
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/alias.c b/alias.c
> index eb9f08b..9938f03 100644
> --- a/alias.c
> +++ b/alias.c
> @@ -5,7 +5,7 @@ static char *alias_val;
>  
>  static int alias_lookup_cb(const char *k, const char *v, void *cb)
>  {
> - if (!prefixcmp(k, "alias.") && !strcmp(k+6, alias_key)) {
> + if (!prefixcmp(k, "alias.") && !strcmp(k + 6, alias_key)) {
>   if (!v)
>   return config_error_nonbool(k);
>   alias_val = xstrdup(v);
> @@ -34,7 +34,7 @@ int split_cmdline(char *cmdline, const char ***argv)
>   int src, dst, count = 0, size = 16;
>   char quoted = 0;
>  
> - *argv = xmalloc(sizeof(char *) * size);
> + *argv = xmalloc(sizeof(**argv) * size);
>  
>   /* split alias_string */
>   (*argv)[count++] = cmdline;
> @@ -45,7 +45,7 @@ int split_cmdline(char *cmdline, const char ***argv)
>   while (cmdline[++src]
>   && isspace(cmdline[src]))
>   ; /* skip */
> - ALLOC_GROW(*argv, count+1, size);
> + ALLOC_GROW(*argv, count + 1, size);
>   (*argv)[count++] = cmdline + dst;
>   } else if (!quoted && (c == '\'' || c == '"')) {
>   quoted = c;
> @@ -76,12 +76,13 @@ int split_cmdline(char *cmdline, const char ***argv)
>   return -SPLIT_CMDLINE_UNCLOSED_QUOTE;
>   }
>  
> - ALLOC_GROW(*argv, count+1, size);
> + ALLOC_GROW(*argv, count + 1, size);
>   (*argv)[count] = NULL;
>  
>   return count;
>  }
>  
> -const char *split_cmdline_strerror(int split_cmdline_errno) {
> - return split_cmdline_errors[-split_cmdline_errno-1];
> +const char *split_cmdline_strerror(int split_cmdline_errno)
> +{
> + return split_cmdline_errors[-split_cmdline_errno - 1];
>  }
> 

--
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/20] revision: trivial style fixes

2013-10-12 Thread Stefan Beller
On 10/12/2013 09:07 AM, Felipe Contreras wrote:
> Signed-off-by: Felipe Contreras 
> ---
>  revision.c | 14 ++
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/revision.c b/revision.c
> index 0173e01..4049867 100644
> --- a/revision.c
> +++ b/revision.c
> @@ -1503,7 +1503,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++);
>   }
>  }
> @@ -1515,7 +1515,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);
>   }
>  }
> @@ -2118,7 +2118,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);
> @@ -2971,7 +2971,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)
> @@ -2986,9 +2986,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) {
>   /*
> @@ -3034,9 +3033,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);
> - }

While talking about trivia, what is the projects stance on
such constructs here?
while (foo)
bar();
foobar();

I've seen an empty line between the bar(); and the foobar(); often, which suits 
readability.
What's the stance on such an empty line here?

>   revs->commits = reversed;
>   revs->reverse = 0;
>   revs->reverse_output_stage = 1;
> 

Thanks,
Stefan

--
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] Add SVN trust-server-cert parameter to git svn to accept SSL server certificates from unknwon authorities without prompting

2013-10-12 Thread arnaud . brejeon
From: arnaudbrejeon 

Signed-off-by: Arnaud Brejeon  gmail.com>
---
 git-svn.perl   |1 +
 perl/Git/SVN/Prompt.pm |9 -
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/git-svn.perl b/git-svn.perl
index 07f0a6c..3dfd4d3 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -124,6 +124,7 @@ $Git::SVN::Fetcher::_placeholder_filename = ".gitignore";
 $_q ||= 0;
 my %remote_opts = ( 'username=s' => \$Git::SVN::Prompt::_username,
 'password=s' => \$Git::SVN::Prompt::_password,
+'trust-server-cert' => 
\$Git::SVN::Prompt::_trust_server_cert,
 'config-dir=s' => \$Git::SVN::Ra::config_dir,
 'no-auth-cache' => \$Git::SVN::Prompt::_no_auth_cache,
 'ignore-paths=s' => \$Git::SVN::Fetcher::_ignore_regex,
diff --git a/perl/Git/SVN/Prompt.pm b/perl/Git/SVN/Prompt.pm
index a94a847..71459ad 100644
--- a/perl/Git/SVN/Prompt.pm
+++ b/perl/Git/SVN/Prompt.pm
@@ -2,7 +2,7 @@ package Git::SVN::Prompt;
 use strict;
 use warnings;
 require SVN::Core;
-use vars qw/$_no_auth_cache $_username $_password/;
+use vars qw/$_no_auth_cache $_username $_password $_trust_server_cert/;
 
 sub simple {
my ($cred, $realm, $default_username, $may_save, $pool) = @_;
@@ -32,6 +32,13 @@ sub simple {
 sub ssl_server_trust {
my ($cred, $realm, $failures, $cert_info, $may_save, $pool) = @_;
$may_save = undef if $_no_auth_cache;
+
+   if ( defined $_trust_server_cert)
+   {
+   $cred->may_save($may_save); 
+   return $SVN::_Core::SVN_NO_ERROR;
+   }
+   
print STDERR "Error validating server certificate for '$realm':\n";
{
no warnings 'once';
-- 
1.7.10.2 (Apple Git-33)

--
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/2] Add password parameter to git svn commands and use it when provided instead of defaulting to end-user prompt

2013-10-12 Thread arnaud . brejeon
From: arnaudbrejeon 

Signed-off-by: Arnaud Brejeon  gmail.com>
---
 git-svn.perl   |3 +++
 perl/Git/SVN/Prompt.pm |   12 +---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index ff1ce3d..07f0a6c 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -123,6 +123,7 @@ sub opt_prefix { return $_prefix || '' }
 $Git::SVN::Fetcher::_placeholder_filename = ".gitignore";
 $_q ||= 0;
 my %remote_opts = ( 'username=s' => \$Git::SVN::Prompt::_username,
+'password=s' => \$Git::SVN::Prompt::_password,
 'config-dir=s' => \$Git::SVN::Ra::config_dir,
 'no-auth-cache' => \$Git::SVN::Prompt::_no_auth_cache,
 'ignore-paths=s' => \$Git::SVN::Fetcher::_ignore_regex,
@@ -206,6 +207,7 @@ my %cmd = (
  'parents' => \$_parents,
  'tag|t' => \$_tag,
  'username=s' => \$Git::SVN::Prompt::_username,
+ 'password=s' => \$Git::SVN::Prompt::_password,
  'commit-url=s' => \$_commit_url } ],
tag => [ sub { $_tag = 1; cmd_branch(@_) },
 'Create a tag in the SVN repository',
@@ -214,6 +216,7 @@ my %cmd = (
   'dry-run|n' => \$_dry_run,
   'parents' => \$_parents,
   'username=s' => \$Git::SVN::Prompt::_username,
+  'password=s' => \$Git::SVN::Prompt::_password,
   'commit-url=s' => \$_commit_url } ],
'set-tree' => [ \&cmd_set_tree,
"Set an SVN repository to a git tree-ish",
diff --git a/perl/Git/SVN/Prompt.pm b/perl/Git/SVN/Prompt.pm
index e940b08..a94a847 100644
--- a/perl/Git/SVN/Prompt.pm
+++ b/perl/Git/SVN/Prompt.pm
@@ -2,7 +2,7 @@ package Git::SVN::Prompt;
 use strict;
 use warnings;
 require SVN::Core;
-use vars qw/$_no_auth_cache $_username/;
+use vars qw/$_no_auth_cache $_username $_password/;
 
 sub simple {
my ($cred, $realm, $default_username, $may_save, $pool) = @_;
@@ -17,8 +17,14 @@ sub simple {
} else {
username($cred, $realm, $may_save, $pool);
}
-   $cred->password(_read_password("Password for '" .
-  $cred->username . "': ", $realm));
+
+   if (defined $_password && length $_password) {
+   $cred->password($_password);
+   } else {
+   $cred->password(_read_password("Password for '" .
+  $cred->username . "': ", 
$realm));
+   }
+
$cred->may_save($may_save);
$SVN::_Core::SVN_NO_ERROR;
 }
-- 
1.7.10.2 (Apple Git-33)

--
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   >