Re: Allow git alias to override existing Git commands

2015-11-10 Thread Sitaram Chamarty
On 11/11/15 01:34, Jeremy Morton wrote:
> On 10/11/2015 18:12, Stefan Beller wrote:
>> On Tue, Nov 10, 2015 at 8:31 AM, Jeremy Morton  wrote:
>>> It's recently come to my attention that the "git alias" config functionality
>>> ignores all aliases that would override existing Git commands.  This seems
>>> like a bad idea to me.
>>
>> This ensures that the plumbing commands always work as expected.
>> As scripts *should* only use plumbing commands, the scripts should
>> work with high probability despite all the crazy user configuration/aliases.
>>
> 
> I just disagree with this.  If a user chooses to override their Git
> commands, it's their problem.  Why should Git care about this?  It
> should provide the user with the option to do this, and if the user
> ruins scripts because of their aliases, it is not Git's problem.  What
> you are doing is taking away power from users to use git aliases to
> their full potential.

A lot of things in Unix do follow that "give you rope to hang yourself"
philosophy.  I used to (and to *some* extent still do) think like that,
but some years of supporting normal users trying to do stuff has taught
me it's not always that simple.

I can easily see someone blogging some cool way to do something, and a
less savvy user uses that in his gitconfig, and gets burned later
(possibly much later, enough that he does not easily make the
connection!)

So for the record, I am definitely against this kind of change.

But if I were in your place, and really *needed* this, here's what I
would do:

#!/bin/bash

# this file is named 'git' and placed in a directory that is earlier in 
$PATH
# than the real 'git' binary (typically $HOME/bin).  This allows you to
# override git sub-commands by adding stuff like this to your ~/.gitconfig
# (notice the "o-" prefix):
#
#   [alias]
#   o-clone = clone --recursive

GIT=/bin/git# the real 'git' binary

cmd="$1"
shift

if $GIT config --get alias.o-$cmd >/dev/null
then
$GIT o-$cmd "$@"
else
$GIT $cmd "$@"
fi
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/7] contrib/subtree: Clean and refactor test code

2015-11-10 Thread David A. Greene
David Greene  writes:

Just a ping to ask if anyone has looked at this.  Apparently send-email
uses the commit author as the From address.  These messages are actually
from me, sent on behalf of the commit authors.

I've got more coming, but want to get these in first as they clean up
the testsuite and will make adding future changes easier.

  -David

> From: Techlive Zheng 
>
> Mostly prepare for the later tests refactoring.  This moves some
> common code to helper functions and generally cleans things up to be
> more presentable.
>
> Signed-off-by: Techlive Zheng 
> Signed-off-by: David A. Greene 
> ---
>  contrib/subtree/t/Makefile |  31 ---
>  contrib/subtree/t/t7900-subtree.sh | 103 
> -
>  2 files changed, 79 insertions(+), 55 deletions(-)
>
> diff --git a/contrib/subtree/t/Makefile b/contrib/subtree/t/Makefile
> index c864810..276898e 100644
> --- a/contrib/subtree/t/Makefile
> +++ b/contrib/subtree/t/Makefile
> @@ -13,11 +13,23 @@ TAR ?= $(TAR)
>  RM ?= rm -f
>  PROVE ?= prove
>  DEFAULT_TEST_TARGET ?= test
> +TEST_LINT ?= test-lint
> +
> +ifdef TEST_OUTPUT_DIRECTORY
> +TEST_RESULTS_DIRECTORY = $(TEST_OUTPUT_DIRECTORY)/test-results
> +else
> +TEST_RESULTS_DIRECTORY = ../../../t/test-results
> +endif
>  
>  # Shell quote;
>  SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
> +PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
> +TEST_RESULTS_DIRECTORY_SQ = $(subst ','\'',$(TEST_RESULTS_DIRECTORY))
>  
> -T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
> +T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
> +TSVN = $(sort $(wildcard t91[0-9][0-9]-*.sh))
> +TGITWEB = $(sort $(wildcard t95[0-9][0-9]-*.sh))
> +THELPERS = $(sort $(filter-out $(T),$(wildcard *.sh)))
>  
>  all: $(DEFAULT_TEST_TARGET)
>  
> @@ -26,20 +38,22 @@ test: pre-clean $(TEST_LINT)
>  
>  prove: pre-clean $(TEST_LINT)
>   @echo "*** prove ***"; GIT_CONFIG=.git/config $(PROVE) --exec 
> '$(SHELL_PATH_SQ)' $(GIT_PROVE_OPTS) $(T) :: $(GIT_TEST_OPTS)
> - $(MAKE) clean
> + $(MAKE) clean-except-prove-cache
>  
>  $(T):
>   @echo "*** $@ ***"; GIT_CONFIG=.git/config '$(SHELL_PATH_SQ)' $@ 
> $(GIT_TEST_OPTS)
>  
>  pre-clean:
> - $(RM) -r test-results
> + $(RM) -r '$(TEST_RESULTS_DIRECTORY_SQ)'
>  
> -clean:
> - $(RM) -r 'trash directory'.* test-results
> +clean-except-prove-cache:
> + $(RM) -r 'trash directory'.* '$(TEST_RESULTS_DIRECTORY_SQ)'
>   $(RM) -r valgrind/bin
> +
> +clean: clean-except-prove-cache
>   $(RM) .prove
>  
> -test-lint: test-lint-duplicates test-lint-executable
> +test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax
>  
>  test-lint-duplicates:
>   @dups=`echo $(T) | tr ' ' '\n' | sed 's/-.*//' | sort | uniq -d` && \
> @@ -51,12 +65,15 @@ test-lint-executable:
>   test -z "$$bad" || { \
>   echo >&2 "non-executable tests:" $$bad; exit 1; }
>  
> +test-lint-shell-syntax:
> + @'$(PERL_PATH_SQ)' ../../../t/check-non-portable-shell.pl $(T) 
> $(THELPERS)
> +
>  aggregate-results-and-cleanup: $(T)
>   $(MAKE) aggregate-results
>   $(MAKE) clean
>  
>  aggregate-results:
> - for f in ../../../t/test-results/t*-*.counts; do \
> + for f in '$(TEST_RESULTS_DIRECTORY_SQ)'/t*-*.counts; do \
>   echo "$$f"; \
>   done | '$(SHELL_PATH_SQ)' ../../../t/aggregate-results.sh
>  
> diff --git a/contrib/subtree/t/t7900-subtree.sh 
> b/contrib/subtree/t/t7900-subtree.sh
> index dfbe443..f9dda3d 100755
> --- a/contrib/subtree/t/t7900-subtree.sh
> +++ b/contrib/subtree/t/t7900-subtree.sh
> @@ -5,7 +5,7 @@
>  #
>  test_description='Basic porcelain support for subtrees
>  
> -This test verifies the basic operation of the merge, pull, add
> +This test verifies the basic operation of the add, pull, merge
>  and split subcommands of git subtree.
>  '
>  
> @@ -20,7 +20,6 @@ create()
>   git add "$1"
>  }
>  
> -
>  check_equal()
>  {
>   test_debug 'echo'
> @@ -38,6 +37,30 @@ undo()
>   git reset --hard HEAD~
>  }
>  
> +# Make sure no patch changes more than one file.
> +# The original set of commits changed only one file each.
> +# A multi-file change would imply that we pruned commits
> +# too aggressively.
> +join_commits()
> +{
> + commit=
> + all=
> + while read x y; do
> + if [ -z "$x" ]; then
> + continue
> + elif [ "$x" = "commit:" ]; then
> + if [ -n "$commit" ]; then
> + echo "$commit $all"
> + all=
> + fi
> + commit="$y"
> + else
> + all="$all $y"
> + fi
> + done
> + echo "$commit $all"
> +}
> +
>  last_commit_message()
>  {
>   git log --pretty=format:%s -1
> @@ -123,9 +146,11 @@ test_expect_success 'add subproj to mainline' '
>   check_equal ''"$(last_commit_message)"'' "Add '"'sub dir/'"' from 
> commit '"'"'

[PATCH 0/5] ff-refs: builtin command to fast-forward local refs

2015-11-10 Thread Michael Rappazzo
This patch series is built on (based on) 'next' because it relies on
worktree.c

`ff-refs` will update local branches which can be fast-forwarded to their
upstream tracking branch.  Any branch which has diverged from the upstream
will be left untouched by this command.  Additionally, there are options
for '--dry-run' and to '--skip-worktrees'.

There are two primary update mechanisms for fast-forwarding a branch.
  - For a checked out branch, emulate `git-merge --ff-only`
  - For a non-checked out branch, emulate `git update-ref`

When run on a repo with multiple worktrees (created with git-worktree add),
git-ff-refs will take that into account when fast-forwarding.  That is, it
will run in 'merge --ff-only' emulation mode when a branch is checked out
in a worktree, rather than in 'update-ref' mode.

The primary benefit of ff-refs will come for those who maintain several
local branches which track upstream remote branches that update often.  The
intended usage pattern is to run `git-fetch` followed by `git-ff-refs`.

Michael Rappazzo (5):
  ff-refs: builtin cmd to check and fast forward local refs to their
upstream
  ff-refs: update each updatable ref
  ff-refs: add --dry-run and --skip-worktree options
  ff-refs: Add documentation
  ff-refs: Add tests

 .gitignore|   1 +
 Documentation/git-ff-refs.txt |  55 +
 Makefile  |   1 +
 builtin.h |   1 +
 builtin/ff-refs.c | 272 ++
 command-list.txt  |   1 +
 git.c |   1 +
 t/t7900-ff-refs.sh| 164 +
 8 files changed, 496 insertions(+)
 create mode 100644 Documentation/git-ff-refs.txt
 create mode 100644 builtin/ff-refs.c
 create mode 100755 t/t7900-ff-refs.sh

-- 
2.6.2

--
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 4/5] ff-refs: Add documentation

2015-11-10 Thread Michael Rappazzo
Signed-off-by: Michael Rappazzo 
---
 Documentation/git-ff-refs.txt | 55 +++
 1 file changed, 55 insertions(+)
 create mode 100644 Documentation/git-ff-refs.txt

diff --git a/Documentation/git-ff-refs.txt b/Documentation/git-ff-refs.txt
new file mode 100644
index 000..569d1d4
--- /dev/null
+++ b/Documentation/git-ff-refs.txt
@@ -0,0 +1,55 @@
+git-ff-refs(1)
+
+
+NAME
+
+git-ff-refs - Fast-forward each local branch to its upstream (if possible)
+
+
+SYNOPSIS
+
+[verse]
+'git ff-refs' []
+
+
+DESCRIPTION
+---
+Update local branches to their tracked upstream if and only if the local branch
+can be fast-forwarded to the upstream ref.  Local branches which have diverged
+from the upstream will not be updated.
+
+Each local branch tracking an upstream will be reported with a status based on
+whether or not it it was updated.  The statuses are:
+
+   UP-TO-DATE - The local branch is the same or equal to the upstream
+   UPDATED - The branch was fast forwarded
+   WOULD-UPDATE - With `--dry-run`, the branch is fast forwardable
+   REMOTE-MISSING - The branch is tracking an upstream that is not present
+   NON-FAST-FORWARD - The branch has diverged from the upstream
+   SKIPPED - With `--skip-worktrees` the branch is fast forwardable but 
checked
+   out in a local worktree
+   WOULD-SKIP - With `--skip-worktrees` and `--dry-run`, the branch is fast
+   forwardable but checked out in a local worktree
+   UNABLE-TO-UPDATE - An error occurred while trying to update the branch
+
+OPTIONS
+---
+--dry-run::
+   Report the updatable state of each branch without acutally updating 
anything.
+   In a dry run, fast-forwardable branches are marked 'WOULD-UPDATE' 
instead of
+   'UPDATED'.
+
+--skip-worktrees::
+   Does not update branches which are checked out in any worktree.  
Branches
+   which are fast-forwardable that are checked out in any worktree are 
marked
+   'SKIPPED'.  If `--dry-run` is also set, those branches are marked 
'WOULD-SKIP'.
+
+
+SEE ALSO
+
+linkgit:git-update-ref[1]
+linkgit:git-merge[1]
+
+GIT
+---
+Part of the linkgit:git[1] suite
-- 
2.6.2

--
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 5/5] ff-refs: Add tests

2015-11-10 Thread Michael Rappazzo
Signed-off-by: Michael Rappazzo 
---
 t/t7900-ff-refs.sh | 164 +
 1 file changed, 164 insertions(+)
 create mode 100755 t/t7900-ff-refs.sh

diff --git a/t/t7900-ff-refs.sh b/t/t7900-ff-refs.sh
new file mode 100755
index 000..3cfbcb8
--- /dev/null
+++ b/t/t7900-ff-refs.sh
@@ -0,0 +1,164 @@
+#!/bin/sh
+
+# SKIPPED
+
+test_description='test ff-refs'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+   test_commit init &&
+   for i in $(test_seq 1 9)
+   do
+   echo "data" >file_$i &&
+   git add file_$i &&
+   git commit -m"Commit $i" &&
+   git branch br_$i
+   done
+'
+
+test_expect_success 'UP-TO-DATE for equal branch' '
+   test_when_finished "rm -rf local" &&
+   git clone . local &&
+   (
+   cd local &&
+   git ff-refs >actual &&
+   grep "UP-TO-DATE" actual
+   )
+'
+
+test_expect_success 'UP-TO-DATE for ahead local branch' '
+   test_when_finished "rm -rf local" &&
+   git clone . local &&
+   (
+   cd local &&
+   git ff-refs >actual &&
+   echo "data" >file_new &&
+   git add file_new &&
+   git commit -m"Commit new" &&
+   grep "UP-TO-DATE" actual
+   )
+'
+
+test_expect_success 'REMOTE-MISSING by local config change' '
+   test_when_finished "rm -rf local" &&
+   git clone . local &&
+   (
+   cd local &&
+   git config --replace branch.master.merge refs/heads/nothing &&
+   git ff-refs >actual &&
+   grep "REMOTE-MISSING" actual
+   )
+'
+
+test_expect_success 'NON-FAST-FORWARD for diverged branch' '
+   test_when_finished "rm -rf local" &&
+   git clone . local &&
+   (
+   cd local &&
+   git reset --hard origin/br_3 &&
+   echo "data" >file_new &&
+   git add file_new &&
+   git commit -m"Commit new" &&
+   git ff-refs >actual &&
+   grep "NON-FAST-FORWARD" actual
+   )
+'
+
+test_expect_success 'UPDATED for fast-forwardable branch' '
+   test_when_finished "rm -rf local" &&
+   git clone . local &&
+   (
+   cd local &&
+   git reset --hard origin/br_3 &&
+   git ff-refs >actual &&
+   grep "UPDATED" actual
+   )
+'
+
+test_expect_success 'WOULD-UPDATE for dry-run on fast-forwardable branch' '
+   test_when_finished "rm -rf local" &&
+   git clone . local &&
+   (
+   cd local &&
+   git reset --hard origin/br_3 &&
+   git ff-refs --dry-run >actual &&
+   grep "WOULD-UPDATE" actual
+   )
+'
+
+test_expect_success 'SKIPPED for skip-worktrees on fast-forwardable branch' '
+   test_when_finished "rm -rf local" &&
+   git clone . local &&
+   (
+   cd local &&
+   git reset --hard origin/br_3 &&
+   git ff-refs --skip-worktrees >actual &&
+   grep "SKIPPED" actual
+   )
+'
+
+test_expect_success 'WOULD-SKIP for dry-run, skip-worktrees on 
fast-forwardable branch' '
+   test_when_finished "rm -rf local" &&
+   git clone . local &&
+   (
+   cd local &&
+   git reset --hard origin/br_3 &&
+   git ff-refs --dry-run --skip-worktrees >actual &&
+   grep "WOULD-SKIP" actual
+   )
+'
+
+test_expect_success 'UPDATE for fast-forwardable, not checked-out branch' '
+   test_when_finished "rm -rf local" &&
+   git clone . local &&
+   (
+   cd local &&
+   git reset --hard origin/br_3 &&
+   git checkout -b other origin/br_3 &&
+   git ff-refs >actual &&
+   grep "master" actual | grep "UPDATED"
+   )
+'
+
+test_expect_success 'UPDATE for fast-forwardable, not checked-out branch using 
--skip-worktrees' '
+   test_when_finished "rm -rf local" &&
+   git clone . local &&
+   (
+   cd local &&
+   git reset --hard origin/br_3 &&
+   git checkout -b other origin/br_3 &&
+   git ff-refs --skip-worktrees >actual &&
+   grep "master" actual | grep "UPDATED"
+   )
+'
+
+test_expect_success 'UPDATE multiple' '
+   test_when_finished "rm -rf local" &&
+   git clone . local &&
+   (
+   cd local &&
+   git reset --hard origin/br_3 &&
+   git checkout -b other origin/br_5 &&
+   git reset --hard origin/br_3 &&
+   git ff-refs >actual &&
+   grep "master" actual | grep "UPDATED" &&
+   grep "other" actual | grep "UPDATED"
+   )
+'
+
+test_expect_success 'UPDATE one, skip worktree on another' '
+   test_when_finished "rm -rf local" &&
+   git clone . local &&
+   (
+   cd local &

[PATCH 3/5] ff-refs: add --dry-run and --skip-worktree options

2015-11-10 Thread Michael Rappazzo
'--dry-run' reports the updatable state of each ref without acutally
updating any refs.  Refs which are fast-forwardable are reported as
'WOULD-UPDATE'.

'--skip-worktrees' does not update refs which are checked out in any
worktree.  Branches which are fast-forwardable but checked out in a
worktree are reported as 'SKIPPED'.  With `--dry-run` these are reported
'WOULD-SKIP'.

Signed-off-by: Michael Rappazzo 
---
 builtin/ff-refs.c | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/builtin/ff-refs.c b/builtin/ff-refs.c
index f14afc5..ae68cfb 100644
--- a/builtin/ff-refs.c
+++ b/builtin/ff-refs.c
@@ -5,6 +5,8 @@
 #include "run-command.h"
 #include "worktree.h"
 
+int dry_run = 0;
+int no_wt = 0;
 struct worktree **worktrees;
 const char *padding = ".";
 
@@ -18,6 +20,7 @@ enum ff_result_type {
UPDATABLE,
REMOTE_MISSING,
NON_FAST_FORWARD,
+   SKIPPED,
UNABLE_TO_UPDATE
 };
 
@@ -48,11 +51,13 @@ static const char *result_type_str(enum ff_result_type 
result_type)
case UP_TO_DATE:
return _("UP-TO-DATE");
case UPDATABLE:
-   return _("WOULD-UPDATE");
+   return dry_run ? _("WOULD-UPDATE") : _("UPDATED");
case REMOTE_MISSING:
return _("REMOTE-MISSING");
case NON_FAST_FORWARD:
return _("NON-FAST-FORWARD");
+   case SKIPPED:
+   return dry_run ? _("WOULD-SKIP") : _("SKIPPED");
default:
return _("UNABLE-TO-UPDATE");
}
@@ -135,7 +140,7 @@ static void process_refs(struct ff_ref_data *data)
 
printf(" %s -> %s%*.*s",
details->branch->name, details->shortened_upstream, 
padLen, padLen, padding);
-   if (details->result_type == UPDATABLE)
+   if (!dry_run && details->result_type == UPDATABLE)
do_ref_update(data, details);
 
printf("[%s]\n", result_type_str(details->result_type));
@@ -208,6 +213,9 @@ static int analize_refs(const char *refname,
else if (!in_merge_bases(details->branch_commit, 
details->upstream_commit))
details->result_type = NON_FAST_FORWARD;
 
+   else if (no_wt && details->wt)
+   details->result_type = SKIPPED;
+
else
details->result_type = UPDATABLE;
}
@@ -233,6 +241,9 @@ int cmd_ff_refs(int argc, const char **argv, const char 
*prefix)
int ret = 0;
 
struct option options[] = {
+   OPT_BOOL(0, "dry-run", &dry_run, N_("show what would be 
fast-forwarded")),
+   OPT_BOOL(0, "skip-worktrees", &no_wt,
+   N_("skip refs checked out in any worktree")),
OPT_END()
};
 
-- 
2.6.2

--
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/5] ff-refs: builtin cmd to check and fast forward local refs to their upstream

2015-11-10 Thread Michael Rappazzo
Each local branch with an upstream remote is checked to see if it can be
fast-forwarded to its upstream.  If fast-forward applies to the branch,
then this is reported to the user.

The statuses are
UP-TO-DATE - The local branch is the same or equal to the upstream
WOULD-UPDATE - The branch would be fast forwarded
REMOTE-MISSING - The branch is tracking an upstream that is not present
NON-FAST-FORWARD - The branch has diverged from the upstream

Signed-off-by: Michael Rappazzo 
---
 .gitignore|   1 +
 Makefile  |   1 +
 builtin.h |   1 +
 builtin/ff-refs.c | 221 ++
 command-list.txt  |   1 +
 git.c |   1 +
 6 files changed, 226 insertions(+)
 create mode 100644 builtin/ff-refs.c

diff --git a/.gitignore b/.gitignore
index 1c2f832..e86a490 100644
--- a/.gitignore
+++ b/.gitignore
@@ -53,6 +53,7 @@
 /git-difftool--helper
 /git-describe
 /git-fast-export
+/git-ff-refs
 /git-fast-import
 /git-fetch
 /git-fetch-pack
diff --git a/Makefile b/Makefile
index 43ceeb9..8e312ad 100644
--- a/Makefile
+++ b/Makefile
@@ -853,6 +853,7 @@ BUILTIN_OBJS += builtin/diff.o
 BUILTIN_OBJS += builtin/fast-export.o
 BUILTIN_OBJS += builtin/fetch-pack.o
 BUILTIN_OBJS += builtin/fetch.o
+BUILTIN_OBJS += builtin/ff-refs.o
 BUILTIN_OBJS += builtin/fmt-merge-msg.o
 BUILTIN_OBJS += builtin/for-each-ref.o
 BUILTIN_OBJS += builtin/fsck.o
diff --git a/builtin.h b/builtin.h
index 6b95006..5680e33 100644
--- a/builtin.h
+++ b/builtin.h
@@ -63,6 +63,7 @@ extern int cmd_diff_tree(int argc, const char **argv, const 
char *prefix);
 extern int cmd_fast_export(int argc, const char **argv, const char *prefix);
 extern int cmd_fetch(int argc, const char **argv, const char *prefix);
 extern int cmd_fetch_pack(int argc, const char **argv, const char *prefix);
+extern int cmd_ff_refs(int argc, const char **argv, const char *prefix);
 extern int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix);
 extern int cmd_for_each_ref(int argc, const char **argv, const char *prefix);
 extern int cmd_format_patch(int argc, const char **argv, const char *prefix);
diff --git a/builtin/ff-refs.c b/builtin/ff-refs.c
new file mode 100644
index 000..94a4649
--- /dev/null
+++ b/builtin/ff-refs.c
@@ -0,0 +1,221 @@
+#include "cache.h"
+#include "refs.h"
+#include "builtin.h"
+#include "remote.h"
+#include "run-command.h"
+#include "worktree.h"
+
+struct worktree **worktrees;
+const char *padding = ".";
+
+static const char * const builtin_ff_refs_usage[] = {
+   N_("git ff-refs []"),
+   NULL
+};
+
+enum ff_result_type {
+   UP_TO_DATE,
+   UPDATABLE,
+   REMOTE_MISSING,
+   NON_FAST_FORWARD,
+   UNABLE_TO_UPDATE
+};
+
+struct ff_ref_details {
+   struct branch *branch;
+   const char *upstream;
+   const char *shortened_upstream;
+   int names_length;
+   enum ff_result_type result_type;
+
+   struct commit *branch_commit;
+   struct commit *upstream_commit;
+   struct commit *merge_base;
+   struct worktree *wt;
+};
+
+struct ff_ref_data {
+   int max_names_length;
+
+   int detail_counter;
+   int detail_alloc;
+   struct ff_ref_details **detail_list;
+};
+
+static const char *result_type_str(enum ff_result_type result_type)
+{
+   switch (result_type) {
+   case UP_TO_DATE:
+   return _("UP-TO-DATE");
+   case UPDATABLE:
+   return _("WOULD-UPDATE");
+   case REMOTE_MISSING:
+   return _("REMOTE-MISSING");
+   case NON_FAST_FORWARD:
+   return _("NON-FAST-FORWARD");
+   default:
+   return _("UNABLE-TO-UPDATE");
+   }
+}
+
+/**
+ * return the worktree with the given refname checked out, or NULL if that
+ * ref is not checked out in any branch.
+ *
+ * This implementation assumes a small number of worktrees (since it loops
+ * through each worktree for every ref).  If a repository has a large number
+ * of worktrees, then it might be beneficial to implement this as a hashmap
+ * lookup instead.
+ */
+static struct worktree *find_worktree(const char *refname)
+{
+   int i = 0;
+
+   for (i = 0; worktrees[i]; i++) {
+   if (!worktrees[i]->is_detached && 
!strcmp(worktrees[i]->head_ref, refname)) {
+   return worktrees[i];
+   }
+   }
+   return NULL;
+}
+
+/**
+ * After all of the relevant refs have been collected, process the
+ * interesting ones
+ */
+static void process_refs(struct ff_ref_data *data)
+{
+   int i = 0;
+
+   for (i = 0; data->detail_list[i]; i++) {
+   struct ff_ref_details *details;
+   int padLen;
+
+   details = data->detail_list[i];
+   padLen = 3 + data->max_names_length - details->names_length;
+   if (padLen < 0)
+   padLen = 0;
+
+   p

[PATCH 2/5] ff-refs: update each updatable ref

2015-11-10 Thread Michael Rappazzo
If an updatable ref is checked out in any worktree, emulate merge
--ff-only to also update the local work tree (including executing the
post-merge hook).

If an updatable ref is not checked out in any worktree, the ref is
simply updated.

If a ref update is successful, that ref is reported as 'UPDATED'.  If
it is not successful, the ref is reported as 'UNABLE-TO-UPDATE'.

Signed-off-by: Michael Rappazzo 
---
 builtin/ff-refs.c | 40 
 1 file changed, 40 insertions(+)

diff --git a/builtin/ff-refs.c b/builtin/ff-refs.c
index 94a4649..f14afc5 100644
--- a/builtin/ff-refs.c
+++ b/builtin/ff-refs.c
@@ -59,6 +59,43 @@ static const char *result_type_str(enum ff_result_type 
result_type)
 }
 
 /**
+ * Do the ref update.
+ *  - If the ref is checked out in any worktree, emulate merge --ff-only to
+ *also update the local work tree (including executing the post-merge 
hook).
+ *
+ *  - If the ref is not checked out in any worktree, update it
+ *
+ *  - If any of the ref updates fails, the result_type is set to 
UNABLE-TO-UPDATE
+ */
+static void do_ref_update(struct ff_ref_data *data, struct ff_ref_details 
*details)
+{
+   const char *refname = details->branch->refname;
+
+   if (details->wt) {
+   struct strbuf path = STRBUF_INIT;
+
+   strbuf_getcwd(&path);
+   chdir(details->wt->path);
+   set_git_dir(details->wt->git_dir);
+   read_index(&the_index);
+
+   if (checkout_fast_forward(details->branch_commit->object.sha1,
+   details->upstream_commit->object.sha1, 1))
+   details->result_type = NON_FAST_FORWARD;
+   else if (update_ref("ff-refs", refname, 
details->upstream_commit->object.sha1,
+   details->branch_commit->object.sha1, 0, 
UPDATE_REFS_QUIET_ON_ERR)) {
+   details->result_type = UNABLE_TO_UPDATE;
+   run_hook_le(NULL, "post-merge", "0", NULL);
+   }
+   discard_index(&the_index);
+   chdir(path.buf);
+   strbuf_release(&path);
+   } else if (update_ref("ff-refs", refname, 
details->upstream_commit->object.sha1,
+   details->branch_commit->object.sha1, 0, 
UPDATE_REFS_QUIET_ON_ERR))
+   details->result_type = UNABLE_TO_UPDATE;
+}
+
+/**
  * return the worktree with the given refname checked out, or NULL if that
  * ref is not checked out in any branch.
  *
@@ -98,6 +135,9 @@ static void process_refs(struct ff_ref_data *data)
 
printf(" %s -> %s%*.*s",
details->branch->name, details->shortened_upstream, 
padLen, padLen, padding);
+   if (details->result_type == UPDATABLE)
+   do_ref_update(data, details);
+
printf("[%s]\n", result_type_str(details->result_type));
}
 }
-- 
2.6.2

--
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] http: fix some printf format warnings on 32-bit builds

2015-11-10 Thread Stefan Beller
On Tue, Nov 10, 2015 at 5:22 PM, Eric Sunshine  wrote:
> On Tue, Nov 10, 2015 at 7:23 PM, Ramsay Jones
>  wrote:
>> Commit f8117f55 ("http: use off_t to store partial file size",
>> 02-11-2015) changed the type of some variables from long to off_t.
>> The 32-bit build, which enables the large filesystem interface
>> (_FILE_OFFSET_BITS == 64), defines the off_t type as a 64-bit
>> integer, whereas long is a 32-bit integer. This results in a couple
>> of printf format warnings.
>>
>> In order to suppress the warnings, change the format specifier to use
>> the PRIuMAX macro and cast the off_t argument to uintmax_t. (See also
>> the http_opt_request_remainder() function, which uses the same
>> solution).
>
> I just ran across the problem when building 'next' on my Mac and was
> about to investigate, so am happy to find that the work has already
> been done. Thanks.
>
> My machine is 64-bit, though, so perhaps it's misleading to
> characterize this as a fix for 32-bit builds. In particular, off_t is
> 'long long' on this machine, so it complains about the "long" format
> specifier.

+Lars

I wonder if 32 bit compilation can be part of travis.
--
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] http: fix some printf format warnings on 32-bit builds

2015-11-10 Thread Eric Sunshine
On Tue, Nov 10, 2015 at 7:23 PM, Ramsay Jones
 wrote:
> Commit f8117f55 ("http: use off_t to store partial file size",
> 02-11-2015) changed the type of some variables from long to off_t.
> The 32-bit build, which enables the large filesystem interface
> (_FILE_OFFSET_BITS == 64), defines the off_t type as a 64-bit
> integer, whereas long is a 32-bit integer. This results in a couple
> of printf format warnings.
>
> In order to suppress the warnings, change the format specifier to use
> the PRIuMAX macro and cast the off_t argument to uintmax_t. (See also
> the http_opt_request_remainder() function, which uses the same
> solution).

I just ran across the problem when building 'next' on my Mac and was
about to investigate, so am happy to find that the work has already
been done. Thanks.

My machine is 64-bit, though, so perhaps it's misleading to
characterize this as a fix for 32-bit builds. In particular, off_t is
'long long' on this machine, so it complains about the "long" format
specifier.

> Signed-off-by: Ramsay Jones 
> ---
> diff --git a/http.c b/http.c
> index 42f29ce..2532976 100644
> --- a/http.c
> +++ b/http.c
> @@ -1617,8 +1617,8 @@ struct http_pack_request *new_http_pack_request(
> if (prev_posn>0) {
> if (http_is_verbose)
> fprintf(stderr,
> -   "Resuming fetch of pack %s at byte %ld\n",
> -   sha1_to_hex(target->sha1), prev_posn);
> +   "Resuming fetch of pack %s at byte 
> %"PRIuMAX"\n",
> +   sha1_to_hex(target->sha1), 
> (uintmax_t)prev_posn);
> http_opt_request_remainder(preq->slot->curl, prev_posn);
> }
>
> @@ -1772,8 +1772,8 @@ struct http_object_request 
> *new_http_object_request(const char *base_url,
> if (prev_posn>0) {
> if (http_is_verbose)
> fprintf(stderr,
> -   "Resuming fetch of object %s at byte %ld\n",
> -   hex, prev_posn);
> +   "Resuming fetch of object %s at byte 
> %"PRIuMAX"\n",
> +   hex, (uintmax_t)prev_posn);
> http_opt_request_remainder(freq->slot->curl, prev_posn);
> }
>
> --
> 2.6.0
--
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] http: fix some printf format warnings on 32-bit builds

2015-11-10 Thread Ramsay Jones

Commit f8117f55 ("http: use off_t to store partial file size",
02-11-2015) changed the type of some variables from long to off_t.
The 32-bit build, which enables the large filesystem interface
(_FILE_OFFSET_BITS == 64), defines the off_t type as a 64-bit
integer, whereas long is a 32-bit integer. This results in a couple
of printf format warnings.

In order to suppress the warnings, change the format specifier to use
the PRIuMAX macro and cast the off_t argument to uintmax_t. (See also
the http_opt_request_remainder() function, which uses the same
solution).

Signed-off-by: Ramsay Jones 
---

Hi Jeff,

I don't compile on 32-bit as often as I did in the past, otherwise I
would have noticed this sooner. :(

ATB,
Ramsay Jones

 http.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/http.c b/http.c
index 42f29ce..2532976 100644
--- a/http.c
+++ b/http.c
@@ -1617,8 +1617,8 @@ struct http_pack_request *new_http_pack_request(
if (prev_posn>0) {
if (http_is_verbose)
fprintf(stderr,
-   "Resuming fetch of pack %s at byte %ld\n",
-   sha1_to_hex(target->sha1), prev_posn);
+   "Resuming fetch of pack %s at byte 
%"PRIuMAX"\n",
+   sha1_to_hex(target->sha1), 
(uintmax_t)prev_posn);
http_opt_request_remainder(preq->slot->curl, prev_posn);
}
 
@@ -1772,8 +1772,8 @@ struct http_object_request *new_http_object_request(const 
char *base_url,
if (prev_posn>0) {
if (http_is_verbose)
fprintf(stderr,
-   "Resuming fetch of object %s at byte %ld\n",
-   hex, prev_posn);
+   "Resuming fetch of object %s at byte 
%"PRIuMAX"\n",
+   hex, (uintmax_t)prev_posn);
http_opt_request_remainder(freq->slot->curl, prev_posn);
}
 
-- 
2.6.0
--
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: git-credential-cache--daemon quits on SIGHUP, can we change it to ignore instead?

2015-11-10 Thread Noam Postavsky
I think you're right about the automated test not being worth the trouble.

On Tue, Nov 10, 2015 at 7:26 AM, Jeff King  wrote:
> To clarify: just telling me it's OK to add your sign-off is fine here. I
> can add it (and fix up the style thing) as I apply.

Ok, please do that then, thanks.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Allow git alias to override existing Git commands

2015-11-10 Thread Stefan Beller
On Tue, Nov 10, 2015 at 1:57 PM, Jens Lehmann  wrote:
> Am 10.11.2015 um 19:12 schrieb Stefan Beller:
>>
>> On Tue, Nov 10, 2015 at 8:31 AM, Jeremy Morton 
>> wrote:
>>>
>>> It's recently come to my attention that the "git alias" config
>>> functionality
>>> ignores all aliases that would override existing Git commands.  This
>>> seems
>>> like a bad idea to me.
>>
>>
>> This ensures that the plumbing commands always work as expected.
>> As scripts *should* only use plumbing commands, the scripts should
>> work with high probability despite all the crazy user
>> configuration/aliases.
>
>
> Exactly.
>
>>> For example, I wanted to setup "git clone" to automatically act as "git
>>> clone --recursive".  Sure I could do it in the shell, but it's more of a
>>> pain - any tutorial I set up about doing it would have to worry about
>>> what
>>> shell the user was using - and if you're going to make that argument, why
>>> have "git alias" at all?  It can all be done from the shell.
>>
>>
>> I think the git way for your example would be to configure git to include
>> that
>> option by default, something like
>>
>>  git config --global submodules.recursiveClone yes
>>
>> though I was skimming through the man page of git config and did not find
>> that option there. I guess it's missing.
>
>
> We thought about adding such a config option, but I believe that would
> fall a bit short. If I want to have recursive clone I also want to init
> all those submodules appearing in later fetches too (otherwise the end
> result would depend on whether you cloned before or after a submodule
> was added upstream, which is confusing). Extra points for populating
> the submodule in my work tree when switching to a commit containing
> the new submodule.
>
> So what about a "submodule.autoupdate" config option? If set to true,
> all submodules not marked "update=none" would automatically be fetched
> and inited by fetch (and thus clone too) and then checked out (with my
> recursive update changes) in every work tree manipulating command
> (again including clone).
>
> Users who only want the submodules to be present in the work tree but
> not automagically updated could set "submodule.autoupdate=clone" to
> avoid the extra cost of updating the work tree every time they switch
> between commits. Now that Heiko's config-from-commit changes are in
> master, someone could easily add that to fetch and clone as the first
> step. We could also teach clone to make "submodule.autoupdate=true"
> imply --recursive and execute the "git submodule" command to update
> the work tree as a first step until the recursive checkout patches
> are ready.
>
> Does that make sense?

I guess.

So the repo tool has the concepts of groups. I plan to add that to git
eventually, too.
i.e. with comma separated list that looks like:

git clone --submodule-groups=default,x86builds,new-phone-codename

Having a new option there there I would also set the

submodule.autoupdate=all

implicitly which then enables --recurse-submodules on all supported commands.

By introducing such a new submodule groups option we don't need to tell
the users about all the new submodule options, but they can still take
advantage of them,
I'd assume.

Does that make sense, too?
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv3 08/11] fetching submodules: respect `submodule.jobs` config option

2015-11-10 Thread Stefan Beller
On Tue, Nov 10, 2015 at 2:21 PM, Jens Lehmann  wrote:
>> +submodule.jobs::
>> +   This is used to determine how many submodules can be operated on in
>> +   parallel. Specifying a positive integer allows up to that number
>> +   of submodules being fetched in parallel. This is used in fetch
>> +   and clone operations only. A value of 0 will give some reasonable
>> +   configuration. It defaults to 1.
>> +
>
>
> Just curious (and sorry if this has already been discussed and I missed
> it, but the volume of your output is too much for my current git time
> budget ;-): While this config is for fetching only, do I recall correctly
> that you have plans to do submodule work tree updates in parallel too?
> If so, would it make sense to have different settings for fetching and
> updating?

TL;DR: checkout is serial, network-related stuff only will be using
submodule.jobs

In the next series (origin/sb/submodule-parallel-update) this is reused for
fetches, clones, so only the network stuff. The checkout (as all local
operations)
is still done serially, as then you don't run into problems in
parallel at the same time.
(checkouts may be parallelized but I haven't done that yet, and postpone that
until it has settled a bit more)
--
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: [PATCHv3 08/11] fetching submodules: respect `submodule.jobs` config option

2015-11-10 Thread Jens Lehmann

Am 04.11.2015 um 01:37 schrieb Stefan Beller:

This allows to configure fetching and updating in parallel
without having the command line option.

This moved the responsibility to determine how many parallel processes
to start from builtin/fetch to submodule.c as we need a way to communicate
"The user did not specify the number of parallel processes in the command
line options" in the builtin fetch. The submodule code takes care of
the precedence (CLI > config > default)

Signed-off-by: Stefan Beller 
---
  Documentation/config.txt|  7 +++
  builtin/fetch.c |  2 +-
  submodule-config.c  | 15 +++
  submodule-config.h  |  2 ++
  submodule.c |  5 +
  t/t5526-fetch-submodules.sh | 14 ++
  6 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 391a0c3..70e1b88 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -2643,6 +2643,13 @@ submodule..ignore::
"--ignore-submodules" option. The 'git submodule' commands are not
affected by this setting.

+submodule.jobs::
+   This is used to determine how many submodules can be operated on in
+   parallel. Specifying a positive integer allows up to that number
+   of submodules being fetched in parallel. This is used in fetch
+   and clone operations only. A value of 0 will give some reasonable
+   configuration. It defaults to 1.
+


Just curious (and sorry if this has already been discussed and I missed
it, but the volume of your output is too much for my current git time
budget ;-): While this config is for fetching only, do I recall correctly
that you have plans to do submodule work tree updates in parallel too?
If so, would it make sense to have different settings for fetching and
updating?


  tag.sort::
This variable controls the sort ordering of tags when displayed by
linkgit:git-tag[1]. Without the "--sort=" option provided, the
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 9cc1c9d..60e6797 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -37,7 +37,7 @@ static int prune = -1; /* unspecified */
  static int all, append, dry_run, force, keep, multiple, update_head_ok, 
verbosity;
  static int progress = -1, recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
  static int tags = TAGS_DEFAULT, unshallow, update_shallow;
-static int max_children = 1;
+static int max_children = -1;
  static const char *depth;
  static const char *upload_pack;
  static struct strbuf default_rla = STRBUF_INIT;
diff --git a/submodule-config.c b/submodule-config.c
index 29e21b2..475551a 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -32,6 +32,7 @@ enum lookup_type {

  static struct submodule_cache cache;
  static int is_cache_init;
+static int parallel_jobs = -1;

  static int config_path_cmp(const struct submodule_entry *a,
   const struct submodule_entry *b,
@@ -239,6 +240,15 @@ static int parse_generic_submodule_config(const char *key,
  const char *value,
  struct parse_config_parameter *me)
  {
+   if (!strcmp(key, "jobs")) {
+   parallel_jobs = strtol(value, NULL, 10);
+   if (parallel_jobs < 0) {
+   warning("submodule.jobs not allowed to be negative.");
+   parallel_jobs = 1;
+   return 1;
+   }
+   }
+
return 0;
  }

@@ -482,3 +492,8 @@ void submodule_free(void)
cache_free(&cache);
is_cache_init = 0;
  }
+
+int config_parallel_submodules(void)
+{
+   return parallel_jobs;
+}
diff --git a/submodule-config.h b/submodule-config.h
index f9e2a29..d9bbf9a 100644
--- a/submodule-config.h
+++ b/submodule-config.h
@@ -27,4 +27,6 @@ const struct submodule *submodule_from_path(const unsigned 
char *commit_sha1,
const char *path);
  void submodule_free(void);

+int config_parallel_submodules(void);
+
  #endif /* SUBMODULE_CONFIG_H */
diff --git a/submodule.c b/submodule.c
index 0257ea3..188ba02 100644
--- a/submodule.c
+++ b/submodule.c
@@ -752,6 +752,11 @@ int fetch_populated_submodules(const struct argv_array 
*options,
argv_array_push(&spf.args, "--recurse-submodules-default");
/* default value, "--submodule-prefix" and its value are added later */

+   if (max_parallel_jobs < 0)
+   max_parallel_jobs = config_parallel_submodules();
+   if (max_parallel_jobs < 0)
+   max_parallel_jobs = 1;
+
calculate_changed_submodule_paths();
run_processes_parallel(max_parallel_jobs,
   get_next_submodule,
diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh
index 1b4ce69..5c3579c 100755
--- a/t/t5526-fetch-submodules.sh
+++ b/t/t5526-fetch-submodules.sh
@@ -470,4 +470,18 @@ test_expect_success "don't fetch submo

Re: Allow git alias to override existing Git commands

2015-11-10 Thread Jens Lehmann

Am 10.11.2015 um 19:12 schrieb Stefan Beller:

On Tue, Nov 10, 2015 at 8:31 AM, Jeremy Morton  wrote:

It's recently come to my attention that the "git alias" config functionality
ignores all aliases that would override existing Git commands.  This seems
like a bad idea to me.


This ensures that the plumbing commands always work as expected.
As scripts *should* only use plumbing commands, the scripts should
work with high probability despite all the crazy user configuration/aliases.


Exactly.


For example, I wanted to setup "git clone" to automatically act as "git
clone --recursive".  Sure I could do it in the shell, but it's more of a
pain - any tutorial I set up about doing it would have to worry about what
shell the user was using - and if you're going to make that argument, why
have "git alias" at all?  It can all be done from the shell.


I think the git way for your example would be to configure git to include that
option by default, something like

 git config --global submodules.recursiveClone yes

though I was skimming through the man page of git config and did not find
that option there. I guess it's missing.


We thought about adding such a config option, but I believe that would
fall a bit short. If I want to have recursive clone I also want to init
all those submodules appearing in later fetches too (otherwise the end
result would depend on whether you cloned before or after a submodule
was added upstream, which is confusing). Extra points for populating
the submodule in my work tree when switching to a commit containing
the new submodule.

So what about a "submodule.autoupdate" config option? If set to true,
all submodules not marked "update=none" would automatically be fetched
and inited by fetch (and thus clone too) and then checked out (with my
recursive update changes) in every work tree manipulating command
(again including clone).

Users who only want the submodules to be present in the work tree but
not automagically updated could set "submodule.autoupdate=clone" to
avoid the extra cost of updating the work tree every time they switch
between commits. Now that Heiko's config-from-commit changes are in
master, someone could easily add that to fetch and clone as the first
step. We could also teach clone to make "submodule.autoupdate=true"
imply --recursive and execute the "git submodule" command to update
the work tree as a first step until the recursive checkout patches
are ready.

Does that make sense?
--
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 0/5] Use watchman to reduce index refresh time

2015-11-10 Thread David Turner
On Mon, 2015-11-09 at 21:06 +0100, Christian Couder wrote:
> Using David's series I get worse results than all of the above but I
> guess it's because his series is based on an ancient git version
> (v2.0.0-rc0).

My more-recent series is on top of 2.4, but (for webkit):
mine: 0m0.206s 
duy's: 0m0.107s

However, I'm getting occasional index-helper segfaults due to
istate->last_update being NULL.  (I'm using Duy's  index-helper branch
from his github + this patchset + a function signature fix due to a
newer version of libwatchman).  I haven't looked into why this is --
maybe accidentally mixing git versions while testing?  

Also, after messing around for a while (on Duy's branch), I ended up in
a state where git status would take ~2.5s every time.  The index helper
was alive but evidently not working right.  Killing and restarting it
worked.  Actually, I think I can repro this more easily: "git rm
Changelog" seems to put the index-helper into this state.



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


Re: [PATCH v5] Add git-grep threads param

2015-11-10 Thread Eric Sunshine
On Tue, Nov 10, 2015 at 8:28 AM, Victor Leschuk  wrote:
> "git grep" can now be configured (or told from the command line)
>  how many threads to use when searching in the working tree files.
>
> Signed-off-by: Victor Leschuk 
> ---

As an aid for reviewers, please use this space (below the "---" line)
to describe what changed since the previous version. It's also helpful
if you can provide a link to the previous version in the mailing list
archive.

>  Documentation/config.txt   |  7 +
>  Documentation/git-grep.txt | 15 ++
>  builtin/grep.c | 50 
> +++---
>  contrib/completion/git-completion.bash |  1 +
>  4 files changed, 57 insertions(+), 16 deletions(-)
>
> diff --git a/Documentation/config.txt b/Documentation/config.txt
> @@ -1447,6 +1447,13 @@ grep.extendedRegexp::
> option is ignored when the 'grep.patternType' option is set to a value
> other than 'default'.
>
> +grep.threads::
> +   Number of grep worker threads, use it to tune up performance on
> +   your machines. Leave it unset (or set to 0) for default behavior,
> +   which for now is using 8 threads for all systems.
> +   Default behavior can be changed in future versions
> +   to better suite hardware and circumstances.

s/suite/suit/ (here and elsewhere)

Was the conclusion of discussion that there should be some explanation
here that this is more about tuning for I/O rather than CPU, or did I
misunderstand?

>  gpg.program::
> Use this custom program instead of "gpg" found on $PATH when
> making or verifying a PGP signature. The program must support the
> diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt
> index 4a44d6d..91027b6 100644
> --- a/Documentation/git-grep.txt
> +++ b/Documentation/git-grep.txt
> diff --git a/builtin/grep.c b/builtin/grep.c
> @@ -832,14 +846,18 @@ int cmd_grep(int argc, const char **argv, const char 
> *prefix)
> }
>
>  #ifndef NO_PTHREADS
> -   if (list.nr || cached || online_cpus() == 1)
> -   use_threads = 0;
> +   if (list.nr || cached)
> +   num_threads = 0; /* Can not multi-thread object lookup */
> +   else if (num_threads == 0)
> +   num_threads = GREP_NUM_THREADS_DEFAULT; /* User didn't 
> specify value, or just wants default behavior */
> +   else if (num_threads < 0)
> +   die("Invalid number of threads specified (%d)", num_threads);

The original code consulted online_cpus(), but the new code does not.
This is a sufficiently significant change that it deserves mention in
the commit message. In fact, it's really a distinct change which might
deserve being done in its own preparatory patch (with an explanation
something along the lines of "even single-core machines may benefit
from threading when the bottleneck is I/O").

>  #else
> -   use_threads = 0;
> +   num_threads = 0;
>  #endif
--
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: Allow git alias to override existing Git commands

2015-11-10 Thread Stefan Beller
On Tue, Nov 10, 2015 at 12:04 PM, Jeremy Morton  wrote:
> On 10/11/2015 18:12, Stefan Beller wrote:
>>
>> On Tue, Nov 10, 2015 at 8:31 AM, Jeremy Morton
>> wrote:
>>>
>>> It's recently come to my attention that the "git alias" config
>>> functionality
>>> ignores all aliases that would override existing Git commands.  This
>>> seems
>>> like a bad idea to me.
>>
>>
>> This ensures that the plumbing commands always work as expected.
>> As scripts *should* only use plumbing commands, the scripts should
>> work with high probability despite all the crazy user
>> configuration/aliases.
>>
>
> I just disagree with this.  If a user chooses to override their Git
> commands, it's their problem.  Why should Git care about this?

Because we still have some Git commands (i.e. git submodule) as scripts,
which would break if the user aliases plumbing commands. This is unexpected,
so should be avoided. Maybe we could allow aliasing porcelain commands though,
but that is extra effort, which nobody looked into yet.

> It should
> provide the user with the option to do this, and if the user ruins scripts
> because of their aliases, it is not Git's problem.  What you are doing is
> taking away power from users to use git aliases to their full potential.

Yeah, no user asked for that power I guess, you're the first. :)

As from your initial email, I think before trying to overriding 'clone'
to 'clone --recurse' you'd rather want to have a globally configured
option to recurse by default on invocation of 'clone'.
That sounds saner to me at least.

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


Re: [PATCH 2/2] contrib/git-candidate: Add README

2015-11-10 Thread David Turner
I didn't actually read the code.  Instead, I started with the README and
decided to provide both text and UX comments all mixed up.  These are
mostly my personal preferences; take them or leave them as you choose. 

I'm really excited about this tool and I think it's got great potential!

On Tue, 2015-11-10 at 12:56 +, Richard Ipsum wrote:
> Describes motivation for git-candidate and shows an example workflow.
> 
> Signed-off-by: Richard Ipsum 
> ---
>  contrib/git-candidate/README.md | 154 
> 
>  1 file changed, 154 insertions(+)
>  create mode 100644 contrib/git-candidate/README.md
> 
> diff --git a/contrib/git-candidate/README.md b/contrib/git-candidate/README.md
> new file mode 100644
> index 000..d2d4437
> --- /dev/null
> +++ b/contrib/git-candidate/README.md
> @@ -0,0 +1,154 @@
> +git-candidate

I have not heard the name "candidate" used this way.  What about "git
codereview"? 

> +=
> +
> +git-candidate provides candidate review and patch tracking,
> +it differs from other tools that provide this by storing _all_
> +content within git.
> +
> +## Why?

I've made a few suggestions below that you might think are out of scope.
If they are, it might be good to have a "non-goals" section so that
people know what the scope of the tool is.

> +Existing tools such as Github's pull-requests and Gerrit are already
> +in wide use, why bother with something new?
> +
> +We 

who?  

> are concerned that whilst 

Today I learned: "whilst" can be used in the sense of "although" (I had
previously thought only "while" could be used this way, but I was wrong!
)

> git is a distributed version control
> +system the systems used to store comments and reviews for content

insert comma after "system"

> +under version control are usually centralised,

replace comma with period.

> +git-candidate aims to solve this by storing
> +all patch-tracking data in git proper.

s/tracking/tracking and review/ ?  Or something

> +## Example review process
> +
> +### Contributor - Submits a candidate
> +
> + (hack hack hack)
> +
> + (feature)$ git commit -m "Add archived repo"
> + (feature)$ git candidate create archivedrepo master
> + -m "Add support for archived repo"
> + Candidate archivedrepo created successfully.
> + (feature)$ git candidate submit origin archivedrepo
> + Candidate was submitted successfully.
> +### Upstream - Reviews candidate

What happens if a third party wants to review candidate?  OR is this
just the same as if upstream does it?

> + (master)$ git candidate fetch origin
> + (master)$ git candidate status origin/archiverepo
> + Revision: 6239bd72d597357af901718becae91cee2a32b73
> + Ref: candidates/origin/archiverepo
> + Status: active
> + Land: master

Could this be "Merge: master"?  Or something that doesn't invent a new
term?

> + Add archived repo support
> +
> +  lib/gitano/command.lua | 28 ++--
> +  1 file changed, 22 insertions(+), 6 deletions(-)
> +
> + (master)$ git show candidates/origin/archiverepo
> + commit 2db28539c8fa7b81122382bcc526c6706c9e113a
> + Author: Richard Ipsum 

Probably better to use example.com addresses in the README rather than
real people.  Git traditionally uses "A U Thor" as the fake name.

> + Date:   Thu Oct 8 10:43:22 2015 +0100
> +
> + Add support for archived repository masking in `ls`
> +
> + By setting `project.archived` to something truthy, a repository
> + is thusly masked from `ls` output unless --all is passed in.
> +
> + Signed-off-by: Richard Ipsum 
> + 
> + 
> +
> +
> + (master)$ git candidate review origin/archiverepo --vote -1
> + -m "Sorry, I'll need to see tests before I can accept this"

Are per-line or per-commit comments supported?  If so, please add an
example of this.

> + (master)$ git candidate submit origin archiverepo
> + Review added successfully

Is the contributor automatically (optionally) emailed on this? If not,
consider this a feature request for this.

> +### Contributor - Revises candidate
> +
> + (master)$ git candidate fetch origin
> + (master)$ git candidate status origin/archiverepo
> + Revision: 6239bd72d597357af901718becae91cee2a32b73
> + Ref: candidates/origin/archiverepo
> + Status: active
> + Land: master
> +
> + Add archived repo support
> +
> +  lib/gitano/command.lua | 28 ++--
> +  1 file changed, 22 insertions(+), 6 deletions(-)
> +
> + 
> 
> + 1 review
> + 
> 
> +
> + Author: Emmet Hikory 
> + Date:   Tue Oct 13 10:09:45 2015 +0100
> + Vote:   -1
> +
> + Sorry, I'll need to see tests before I can accept this
> +
> + 
> ---

Announcing Git for Windows 2.6.3

2015-11-10 Thread Johannes Schindelin
Dear Git users,

it is my pleasure to announce that Git for Windows 2.6.3 is available from
https://git-for-windows.github.io/

Changes since Git for Windows v2.6.2 (October 19th 2015)

New Features

  • Comes with Git v2.6.3.
  • Enables the stack smasher to protect against buffer overflows.

Bug Fixes

  • Git Bash works now even when choosing Windows' default console and
installing into a short path (e.g. C:\Git).
  • Notepad can now really be used to edit commit messages.
  • Git's garbage collector now handles stale refs/remotes/origin/HEAD
gracefully.
  • The regression in Git for Windows 2.6.2 that it required administrator
privileges to be installed is now fixed.
  • When notepad is configured as default editor, we no longer do anything
specially unless editing files inside .git/.

Ciao,
Johannes

Re: Allow git alias to override existing Git commands

2015-11-10 Thread Jeremy Morton

On 10/11/2015 18:12, Stefan Beller wrote:

On Tue, Nov 10, 2015 at 8:31 AM, Jeremy Morton  wrote:

It's recently come to my attention that the "git alias" config functionality
ignores all aliases that would override existing Git commands.  This seems
like a bad idea to me.


This ensures that the plumbing commands always work as expected.
As scripts *should* only use plumbing commands, the scripts should
work with high probability despite all the crazy user configuration/aliases.



I just disagree with this.  If a user chooses to override their Git 
commands, it's their problem.  Why should Git care about this?  It 
should provide the user with the option to do this, and if the user 
ruins scripts because of their aliases, it is not Git's problem.  What 
you are doing is taking away power from users to use git aliases to 
their full potential.


--
Best regards,
Jeremy Morton (Jez)
--
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: gitk fails to start after upgrading to 2.6.3 (cannot load translation)

2015-11-10 Thread Beat Bolli
On 10.11.15 10:48, Peter Krefting wrote:
> Hi!
> 
> After upgrading Git to 2.6.3 (from 2.5.0), gitk refuses to start when
> trying to load the Swedish translation if I pass it a commit range:

The patch can be found here:

http://article.gmane.org/gmane.comp.version-control.git/278863

Cheers,
Beat
--
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: Allow git alias to override existing Git commands

2015-11-10 Thread Stefan Beller
On Tue, Nov 10, 2015 at 8:31 AM, Jeremy Morton  wrote:
> It's recently come to my attention that the "git alias" config functionality
> ignores all aliases that would override existing Git commands.  This seems
> like a bad idea to me.

This ensures that the plumbing commands always work as expected.
As scripts *should* only use plumbing commands, the scripts should
work with high probability despite all the crazy user configuration/aliases.

>
> For example, I wanted to setup "git clone" to automatically act as "git
> clone --recursive".  Sure I could do it in the shell, but it's more of a
> pain - any tutorial I set up about doing it would have to worry about what
> shell the user was using - and if you're going to make that argument, why
> have "git alias" at all?  It can all be done from the shell.

I think the git way for your example would be to configure git to include that
option by default, something like

git config --global submodules.recursiveClone yes

though I was skimming through the man page of git config and did not find
that option there. I guess it's missing.


>
> Obviously I could also use a different alias that wasn't an existing Git
> command for this behaviour, but that would rather defeat the point: I want
> "git clone" to have different functionality.  If I remembered to use a
> different Git command, I might as well remember to type "git clone
> --recursive".  Also, if a future Git command were introduced with the same
> name as my alias, my alias's functionality would suddenly be ignored, giving
> unexpected behaviour.
>
> The reasoning behind this that it's "to avoid confusion and troubles with
> script usage" seems to be at odds with the general Git mentality that the
> user is given lots of power, and if they screw it up it's basically just
> user error.

For scripting the plumbing commands are recommended. The plumbing commands
usually cannot be configured to do crazy stuff.

> For example, Git doesn't *have* to allow you to rebase.  It's a
> potentially dangerous operation, so why is it allowed?  It might "cause
> confusion and troubles".

Git doesn't try to hide its complexity from the users. And if a user would need
to hack their way around to get rebasing working again, might also
"cause confusion
and troubles".

>
> On the other hand, by disallowing the overriding of existing Git commands
> through aliases you are preventing a lot of useful functionality that those
> aliases might be used for.
>
> So I think you should either allow Git aliases to override existing Git
> commands by default, or at least provide a config option that allows the
> user to say that this should happen.
>
> --
> Best regards,
> Jeremy Morton (Jez)
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] contrib/subtree: remove "push" command from the "todo" file

2015-11-10 Thread Fabio Porcedda
Because the "push" command is already available, remove it from the
"todo" file.

Signed-off-by: Fabio Porcedda 
---
 contrib/subtree/todo | 2 --
 1 file changed, 2 deletions(-)

diff --git a/contrib/subtree/todo b/contrib/subtree/todo
index 7e44b00..0d0e777 100644
--- a/contrib/subtree/todo
+++ b/contrib/subtree/todo
@@ -12,8 +12,6 @@
exactly the right subtree structure, rather than using
subtree merge...)
 
-   add a 'push' subcommand to parallel 'pull'
-   
add a 'log' subcommand to see what's new in a subtree?
 
add to-submodule and from-submodule commands
-- 
2.6.2

--
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] contrib/subtree: remove "push" command from the "todo" file

2015-11-10 Thread Eric Sunshine
On Tue, Nov 10, 2015 at 12:58 PM, Fabio Porcedda
 wrote:
> On Thu, Nov 5, 2015 at 11:57 PM, Eric Sunshine 
> wrote:
>> On Thu, Nov 5, 2015 at 10:26 AM, Fabio Porcedda
>>  wrote:
>> > Because the "push" command is already avaiable, remove it from the
>>
>> s/avaiable/available/
>
> Thanks, i will send an updated version.

I don't think you need to re-send. Junio already fixed that typo when
he queued[1] it in his 'pu' branch.

[1]: 4547039 (contrib/subtree: remove "push" command from the "todo"
file, 2015-11-05)
--
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


Allow git alias to override existing Git commands

2015-11-10 Thread Jeremy Morton
It's recently come to my attention that the "git alias" config 
functionality ignores all aliases that would override existing Git 
commands.  This seems like a bad idea to me.


For example, I wanted to setup "git clone" to automatically act as 
"git clone --recursive".  Sure I could do it in the shell, but it's 
more of a pain - any tutorial I set up about doing it would have to 
worry about what shell the user was using - and if you're going to 
make that argument, why have "git alias" at all?  It can all be done 
from the shell.


Obviously I could also use a different alias that wasn't an existing 
Git command for this behaviour, but that would rather defeat the 
point: I want "git clone" to have different functionality.  If I 
remembered to use a different Git command, I might as well remember to 
type "git clone --recursive".  Also, if a future Git command were 
introduced with the same name as my alias, my alias's functionality 
would suddenly be ignored, giving unexpected behaviour.


The reasoning behind this that it's "to avoid confusion and troubles 
with script usage" seems to be at odds with the general Git mentality 
that the user is given lots of power, and if they screw it up it's 
basically just user error.  For example, Git doesn't *have* to allow 
you to rebase.  It's a potentially dangerous operation, so why is it 
allowed?  It might "cause confusion and troubles".


On the other hand, by disallowing the overriding of existing Git 
commands through aliases you are preventing a lot of useful 
functionality that those aliases might be used for.


So I think you should either allow Git aliases to override existing 
Git commands by default, or at least provide a config option that 
allows the user to say that this should happen.


--
Best regards,
Jeremy Morton (Jez)
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[bug] git 2.6.2 (64-bit) blocks keyboard input (running in RDP, Win7 x64)

2015-11-10 Thread Ryabov, Vasily V
 Hi,

I'm trying to run something like this (on the remote machine (Win7 x64 with git 
2.6.2 64-bit) through RDP):
```
git pull --tags --progress ssh://@:/ 
+refs/heads/*:refs/remotes/origin/*
```
It worked on local machine with git 1.9.5.

Git asks to confirm an action:
```
The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's dss key fingerprint is:
ssh-dss 1024 <...>
If you trust this host, enter "y" to add the key to
PuTTY's cache and carry on connecting.
If you want to carry on connecting just once, without
adding the key to the cache, enter "n".
If you do not trust this host, press Return to abandon the
connection.
Store key in cache? (y/n)
```
I'm typing `y`, but there is no reaction at all. No symbols appears in the 
console. But...
When I'm pressing `Ctrl+C`, it's killed. And I can see `y` keys in the bash 
console for the next command.

On-screen keyboard didn't help as well.

I've already tried several combinations of `MinTTY` and `Windows cmd.exe` check 
boxes in the installer. Nothing helped.
It looks like a bug in Git client.

Best regards,
-Vasily.


Joint Stock Company Intel A/O
Registered legal address: Krylatsky Hills Business Park,
17 Krylatskaya Str., Bldg 4, Moscow 121614,
Russian Federation

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

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


[PATCH v5] Add git-grep threads param

2015-11-10 Thread Victor Leschuk
"git grep" can now be configured (or told from the command line)
 how many threads to use when searching in the working tree files.

Signed-off-by: Victor Leschuk 
---
 Documentation/config.txt   |  7 +
 Documentation/git-grep.txt | 15 ++
 builtin/grep.c | 50 +++---
 contrib/completion/git-completion.bash |  1 +
 4 files changed, 57 insertions(+), 16 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 391a0c3..467fa7b 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1447,6 +1447,13 @@ grep.extendedRegexp::
option is ignored when the 'grep.patternType' option is set to a value
other than 'default'.
 
+grep.threads::
+   Number of grep worker threads, use it to tune up performance on
+   your machines. Leave it unset (or set to 0) for default behavior,
+   which for now is using 8 threads for all systems.
+   Default behavior can be changed in future versions
+   to better suite hardware and circumstances.
+
 gpg.program::
Use this custom program instead of "gpg" found on $PATH when
making or verifying a PGP signature. The program must support the
diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt
index 4a44d6d..91027b6 100644
--- a/Documentation/git-grep.txt
+++ b/Documentation/git-grep.txt
@@ -23,6 +23,7 @@ SYNOPSIS
   [--break] [--heading] [-p | --show-function]
   [-A ] [-B ] [-C ]
   [-W | --function-context]
+  [--threads ]
   [-f ] [-e] 
   [--and|--or|--not|(|)|-e ...]
   [ [--[no-]exclude-standard] [--cached | --no-index | --untracked] | 
...]
@@ -53,6 +54,13 @@ grep.extendedRegexp::
option is ignored when the 'grep.patternType' option is set to a value
other than 'default'.
 
+grep.threads::
+   Number of grep worker threads, use it to tune up performance on
+   your machines. Leave it unset (or set to 0) for default behavior,
+   which for now is using 8 threads for all systems.
+   Default behavior can be changed in future versions
+   to better suite hardware and circumstances.
+
 grep.fullName::
If set to true, enable '--full-name' option by default.
 
@@ -227,6 +235,13 @@ OPTIONS
effectively showing the whole function in which the match was
found.
 
+--threads ::
+   Number of grep worker threads, use it to tune up performance on
+   your machines. Leave it unset (or set to 0) for default behavior,
+   which for now is using 8 threads for all systems.
+   Default behavior can be changed in future versions
+   to better suite hardware and circumstances.
+
 -f ::
Read patterns from , one per line.
 
diff --git a/builtin/grep.c b/builtin/grep.c
index d04f440..f0e3dfb 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -24,11 +24,11 @@ static char const * const grep_usage[] = {
NULL
 };
 
-static int use_threads = 1;
+#define GREP_NUM_THREADS_DEFAULT 8
+static int num_threads = 0;
 
 #ifndef NO_PTHREADS
-#define THREADS 8
-static pthread_t threads[THREADS];
+static pthread_t *threads;
 
 /* We use one producer thread and THREADS consumer
  * threads. The producer adds struct work_items to 'todo' and the
@@ -63,13 +63,13 @@ static pthread_mutex_t grep_mutex;
 
 static inline void grep_lock(void)
 {
-   if (use_threads)
+   if (num_threads)
pthread_mutex_lock(&grep_mutex);
 }
 
 static inline void grep_unlock(void)
 {
-   if (use_threads)
+   if (num_threads)
pthread_mutex_unlock(&grep_mutex);
 }
 
@@ -206,7 +206,8 @@ static void start_threads(struct grep_opt *opt)
strbuf_init(&todo[i].out, 0);
}
 
-   for (i = 0; i < ARRAY_SIZE(threads); i++) {
+   threads = xcalloc(num_threads, sizeof(pthread_t));
+   for (i = 0; i < num_threads; i++) {
int err;
struct grep_opt *o = grep_opt_dup(opt);
o->output = strbuf_out;
@@ -238,12 +239,14 @@ static int wait_all(void)
pthread_cond_broadcast(&cond_add);
grep_unlock();
 
-   for (i = 0; i < ARRAY_SIZE(threads); i++) {
+   for (i = 0; i < num_threads; i++) {
void *h;
pthread_join(threads[i], &h);
hit |= (int) (intptr_t) h;
}
 
+   free(threads);
+
pthread_mutex_destroy(&grep_mutex);
pthread_mutex_destroy(&grep_read_mutex);
pthread_mutex_destroy(&grep_attr_mutex);
@@ -262,10 +265,19 @@ static int wait_all(void)
 }
 #endif
 
+static int grep_threads_config(const char *var, const char *value, void *cb)
+{
+   if (!strcmp(var, "grep.threads"))
+   num_threads = git_config_int(var, value); /* Sanity check of 
value will be perfomed later */
+   return 0;
+}
+
 static int grep_cmd_config(const char *var, const char *value, void *cb)
 {
int st = g

[PATCH 1/2] contrib: Add git-candidate subcommand

2015-11-10 Thread Richard Ipsum
git-candidate provides candidate review and patch tracking,
allowing distributed comment and review facilities with
all content stored in git.

Signed-off-by: Richard Ipsum 
---
 contrib/git-candidate/GitUtils.pm|  207 +++
 contrib/git-candidate/git-candidate.perl | 2541 ++
 2 files changed, 2748 insertions(+)
 create mode 100644 contrib/git-candidate/GitUtils.pm
 create mode 100755 contrib/git-candidate/git-candidate.perl

diff --git a/contrib/git-candidate/GitUtils.pm 
b/contrib/git-candidate/GitUtils.pm
new file mode 100644
index 000..24c9abe
--- /dev/null
+++ b/contrib/git-candidate/GitUtils.pm
@@ -0,0 +1,207 @@
+# Copyright 2015 Codethink Limited
+#
+# GPL v2 (See COPYING)
+
+package GitUtils;
+
+use Exporter 'import';
+use Error qw(:try);
+use Git;
+
+our @EXPORT_OK = qw(require_clean_work_tree git_editor _head_symbolic_ref
+ _command_input_pipe_capture_output_oneline cat_file
+ is_object_present is_commit_merged get_head_branch
+ get_head_commit get_land_for_commit get_sha_at_ref
+ get_tracking_branch remove_refs inject_json
+ looks_like_sha validate_kwargs);
+
+use Carp;
+sub validate_kwargs
+{
+my ($kwargs_ref, @mandatory_args) = @_;
+
+for my $k (@mandatory_args) {
+confess "No '$k' provided" unless exists $kwargs_ref->{$k};
+}
+}
+
+sub looks_like_sha
+{
+my $x = shift;
+return $x =~ /[0-9a-z]{40}/;
+}
+
+sub inject_json
+{
+my ($repo, $json) = @_;
+my $fh = File::Temp->new();
+
+print $fh $json;
+close $fh;
+my $hash = $repo->hash_and_insert_object($fh->filename);
+
+return $hash;
+}
+
+sub require_clean_work_tree {
+my ($repo, $action) = @_;
+$action //= 'proceed';
+my $errno = 0;
+
+try {
+$repo->command_oneline('diff-files', '--quiet', '--ignore-submodules');
+}
+catch Git::Error::Command with {
+print STDERR "Cannot $action: You have unstaged changes.\n";
+$errno = 1;
+};
+
+try {
+$repo->command('diff-index', '--cached', '--quiet',
+'--ignore-submodules', 'HEAD');
+}
+catch Git::Error::Command with {
+if ($errno == 0) {
+print STDERR "Cannot $action: Your index contains uncommitted 
changes.\n";
+$errno = 1;
+}
+else {
+print STDERR "Additonally, your index contains uncommitted 
changes.\n";
+}
+};
+
+exit 1 if $errno;
+}
+
+sub git_editor
+{
+my $editor = $ENV{GIT_EDITOR} // `git var GIT_EDITOR`;
+chomp($editor);
+
+system($editor, @_);
+}
+
+sub _head_symbolic_ref
+{
+my $repo = shift;
+return $repo->command_oneline(['symbolic-ref', 'HEAD'], STDERR => 0);
+}
+
+sub _command_input_pipe_capture_output_oneline
+{
+my ($repo, $command_input, $command, @arguments) = @_;
+
+confess "No repo defined" unless defined $repo;
+confess "No command input defined" unless defined $command_input;
+confess "No command defined" unless defined $command;
+
+my ($pid, $pipe_out, $pipe_in, $ctx) = $repo->command_bidi_pipe($command,
+@arguments);
+print $pipe_in $command_input;
+close $pipe_in;
+
+my $output = readline $pipe_out;
+chomp($output) if $output;
+
+$repo->command_close_bidi_pipe($pid, $pipe_out, undef, $ctx);
+
+return $output;
+}
+
+sub cat_file
+{
+my ($repo, $sha, $filename, %kwargs) = @_;
+return $repo->command(['cat-file', '-p',
+defined $filename ? "$sha:$filename" : "$sha"], %kwargs);
+}
+
+sub is_object_present
+{
+my ($repo, $sha) = @_;
+
+return try {
+my $output = $repo->command_oneline(['cat-file', '-t', $sha],
+STDERR => 0);
+return 1;
+}
+catch Git::Error::Command with {
+return 0;
+};
+}
+
+sub is_commit_merged
+{
+my ($repo, $what, $where) = @_;
+my @lines = $repo->command('rev-list', $where);
+return grep { /$what/ } @lines;
+}
+
+sub get_head_branch
+{
+my $repo = shift;
+
+return try {
+my $symbolic_ref = _head_symbolic_ref($repo);
+return $repo->command_oneline('for-each-ref',
+'--format=%(refname:short)', $symbolic_ref);
+}
+catch Git::Error::Command with {
+return undef;
+};
+}
+
+sub get_head_commit
+{
+my $repo = shift;
+
+return try {
+return $repo->command_oneline('rev-parse', 'HEAD');
+}
+catch Git::Error::Command with {
+return undef;
+};
+}
+
+sub get_land_for_commit
+{
+my ($repo, $commit) = @_;
+
+return try {
+my $symbolic_ref = _head_symbolic_ref($repo);
+my $line = $repo->command_oneline('for-each-ref',
+'--format=%(upstream) %(upstream:short)', $symbolic_ref);
+my ($unambig, $land) = split(/ /, $line);
+my $ontop = $repo->command_oneline('merge-base', $commit, $unambig);
+print "returning hash...";
+return {ontop => $ontop, land

[PATCH 0/2] git-candidate: git based patch tracking and review

2015-11-10 Thread Richard Ipsum
Hi,

I've continued my work[1] to add patch tracking and candidate review capability
to git.

git-candidate now has a more git-like user interface, so remote candidates
can now be specified in a similar way to remote refs (e.g. origin/candidate)
as well as various other improvements, such as versioned metadata.

[1]: http://www.mail-archive.com/git%40vger.kernel.org/msg79461.html

Richard Ipsum (2):
  contrib: Add git-candidate subcommand
  contrib/git-candidate: Add README

 contrib/git-candidate/GitUtils.pm|  207 +++
 contrib/git-candidate/README.md  |  154 ++
 contrib/git-candidate/git-candidate.perl | 2541 ++
 3 files changed, 2902 insertions(+)
 create mode 100644 contrib/git-candidate/GitUtils.pm
 create mode 100644 contrib/git-candidate/README.md
 create mode 100755 contrib/git-candidate/git-candidate.perl

-- 
2.1.4

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


[PATCH 2/2] contrib/git-candidate: Add README

2015-11-10 Thread Richard Ipsum
Describes motivation for git-candidate and shows an example workflow.

Signed-off-by: Richard Ipsum 
---
 contrib/git-candidate/README.md | 154 
 1 file changed, 154 insertions(+)
 create mode 100644 contrib/git-candidate/README.md

diff --git a/contrib/git-candidate/README.md b/contrib/git-candidate/README.md
new file mode 100644
index 000..d2d4437
--- /dev/null
+++ b/contrib/git-candidate/README.md
@@ -0,0 +1,154 @@
+git-candidate
+=
+
+git-candidate provides candidate review and patch tracking,
+it differs from other tools that provide this by storing _all_
+content within git.
+
+## Why?
+
+Existing tools such as Github's pull-requests and Gerrit are already
+in wide use, why bother with something new?
+
+We are concerned that whilst git is a distributed version control
+system the systems used to store comments and reviews for content
+under version control are usually centralised,
+git-candidate aims to solve this by storing
+all patch-tracking data in git proper.
+
+## Example review process
+
+### Contributor - Submits a candidate
+
+   (hack hack hack)
+
+   (feature)$ git commit -m "Add archived repo"
+   (feature)$ git candidate create archivedrepo master
+   -m "Add support for archived repo"
+   Candidate archivedrepo created successfully.
+   (feature)$ git candidate submit origin archivedrepo
+   Candidate was submitted successfully.
+
+### Upstream - Reviews candidate
+
+   (master)$ git candidate fetch origin
+   (master)$ git candidate status origin/archiverepo
+   Revision: 6239bd72d597357af901718becae91cee2a32b73
+   Ref: candidates/origin/archiverepo
+   Status: active
+   Land: master
+
+   Add archived repo support
+
+lib/gitano/command.lua | 28 ++--
+1 file changed, 22 insertions(+), 6 deletions(-)
+
+   (master)$ git show candidates/origin/archiverepo
+   commit 2db28539c8fa7b81122382bcc526c6706c9e113a
+   Author: Richard Ipsum 
+   Date:   Thu Oct 8 10:43:22 2015 +0100
+
+   Add support for archived repository masking in `ls`
+
+   By setting `project.archived` to something truthy, a repository
+   is thusly masked from `ls` output unless --all is passed in.
+
+   Signed-off-by: Richard Ipsum 
+   
+   
+
+
+   (master)$ git candidate review origin/archiverepo --vote -1
+   -m "Sorry, I'll need to see tests before I can accept this"
+   (master)$ git candidate submit origin archiverepo
+   Review added successfully
+
+### Contributor - Revises candidate
+
+   (master)$ git candidate fetch origin
+   (master)$ git candidate status origin/archiverepo
+   Revision: 6239bd72d597357af901718becae91cee2a32b73
+   Ref: candidates/origin/archiverepo
+   Status: active
+   Land: master
+
+   Add archived repo support
+
+lib/gitano/command.lua | 28 ++--
+1 file changed, 22 insertions(+), 6 deletions(-)
+
+   

+   1 review
+   

+
+   Author: Emmet Hikory 
+   Date:   Tue Oct 13 10:09:45 2015 +0100
+   Vote:   -1
+
+   Sorry, I'll need to see tests before I can accept this
+
+   

+
+   (hack hack hack add tests)
+
+   (feature_v2)$ git log --oneline -1
+   Ensure the `ls` yarn checks for archived repos
+
+   (feature_v2)$ git candidate revise origin/archiverepo
+   -m "Add archived repo support with tests"
+   Candidate archiverepo revised successfully.
+
+   (feature_v2)$ git candidate submit origin archiverepo
+   Candidate was submitted successfully.
+
+### Upstream - Merges candidate
+
+   (master)$ git candidate fetch origin
+   (master)$ git candidate status origin/archiverepo
+   Revision: 4cd3d1197d399005a713ca55f126a9086356a072
+   Ref: candidates/origin/archiverepo
+   Status: active
+   Land: master
+
+   Add archived repo support with tests
+
+lib/gitano/command.lua  | 28 ++--
+testing/02-commands-ls.yarn | 19 +++
+2 files changed, 41 insertions(+), 6 deletions(-)
+
+   (master)$ git candidate review origin/archiverepo --vote +2
+   -m "Looks good, merging.  Thanks for your efforts"
+   Review added successfully
+
+   (master)$ git candidate submit origin archiverepo
+   Candidate was submitted successfully.
+
+   (master)$ git merge candidates/origin/archiverepo
+   (master)$ git push origin master
+
+### Contributor - Observes candidate has been accepted
+
+   (feature_v2)$ git candidate fetch origin
+   (fe

Re: git-credential-cache--daemon quits on SIGHUP, can we change it to ignore instead?

2015-11-10 Thread Jeff King
On Tue, Nov 10, 2015 at 07:25:02AM -0500, Jeff King wrote:

> > Introduce new option "credentialCache.ignoreSIGHUP" which stops
> > git-credential-cache--daemon from quitting on SIGHUP.  This is useful
> > when "git push" is started from Emacs, because all child
> > processes (including the daemon) will receive a SIGHUP when "git push"
> > exits.
> > ---
> 
> Can you add a signed-off-by here (see the "sign-off" section in
> Documentation/SubmittingPatches).

To clarify: just telling me it's OK to add your sign-off is fine here. I
can add it (and fix up the style thing) as I apply.

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


Re: git-credential-cache--daemon quits on SIGHUP, can we change it to ignore instead?

2015-11-10 Thread Jeff King
On Mon, Nov 09, 2015 at 08:05:25PM -0500, Noam Postavsky wrote:

> > Automated tests would be nice, but I suspect it may be too complicated
> > to be worth it.
> 
> I attempted
> 
> test_ignore_sighup ()
> {
> mkdir "$HOME/.git-credential-cache" &&
> chmod 0700 "$HOME/.git-credential-cache" &&
> git -c credentialCache.ignoreSIGHUP=true credential-cache--daemon
> "$HOME/.git-credential-cache/socket" &
> kill -SIGHUP $! &&
> ps $!
> }
> 
> test_expect_success 'credentialCache.ignoreSIGHUP works' 'test_ignore_sighup'
> 
> but it does't pass (testing manually by running
> ./git-credential-cache--daemon $HOME/.git-credential-cache/test-socket
> & and then kill -HUP does work).

Your test looks racy. After the "&" in spawning the daemon, we don't
have any guarantee that the daemon actually reached the signal() call
before we issued our kill.

The daemon issues an "ok\n" to stdout to report that it's ready to serve
(this is how the auto-spawn avoids races). So you could use that with a
fifo to fix this. It's a little complicated; see lib-git-daemon.sh for
an example.

I'm also not sure the use of "ps" here is portable (i.e., does it always
report a useful error code on all systems?).

So I dunno. Given the complexity of the test, and that it is such a
simple feature that is unlikely to be broken, I'm not sure it is worth
it. A test failure seems like it would more likely be a problem in the
test, not the code.

> From 5fc95b6e2f956403da6845fc3ced83b21bee7bb0 Mon Sep 17 00:00:00 2001
> From: Noam Postavsky 
> Date: Mon, 9 Nov 2015 19:26:29 -0500
> Subject: [PATCH] credential-cache: new option to ignore sighup
> 
> Introduce new option "credentialCache.ignoreSIGHUP" which stops
> git-credential-cache--daemon from quitting on SIGHUP.  This is useful
> when "git push" is started from Emacs, because all child
> processes (including the daemon) will receive a SIGHUP when "git push"
> exits.
> ---

Can you add a signed-off-by here (see the "sign-off" section in
Documentation/SubmittingPatches).

> diff --git a/credential-cache--daemon.c b/credential-cache--daemon.c
> index eef6fce..6cda9c0 100644
> --- a/credential-cache--daemon.c
> +++ b/credential-cache--daemon.c
> @@ -256,6 +256,9 @@ int main(int argc, const char **argv)
>   OPT_END()
>   };
>  
> + int ignore_sighup = 0;
> + git_config_get_bool("credentialcache.ignoresighup", &ignore_sighup);
> +

Style-wise, I think the declaration should go above the options-list.

> @@ -264,6 +267,10 @@ int main(int argc, const char **argv)
>  
>   check_socket_directory(socket_path);
>   register_tempfile(&socket_file, socket_path);
> +
> + if (ignore_sighup)
> + signal(SIGHUP, SIG_IGN);
> +

This part looks obviously correct. :)

I don't think there's any need to use sigchain_push here (we have no
intention of ever popping it).

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


[PATCH v8 03/10] copy_msg(): rename to copy_reflog_msg()

2015-11-10 Thread Michael Haggerty
From: David Turner 

We will soon increase the visibility of this function, so make its name
more distinctive.

Signed-off-by: David Turner 
Signed-off-by: Junio C Hamano 
Signed-off-by: Michael Haggerty 
---
 refs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/refs.c b/refs.c
index ddcdf81..480de9a 100644
--- a/refs.c
+++ b/refs.c
@@ -3287,7 +3287,7 @@ static int commit_ref(struct ref_lock *lock)
  * large, while cleaning up the whitespaces.  Especially, convert LF to space,
  * because reflog file is one line per entry.
  */
-static int copy_msg(char *buf, const char *msg)
+static int copy_reflog_msg(char *buf, const char *msg)
 {
char *cp = buf;
char c;
@@ -3391,7 +3391,7 @@ static int log_ref_write_fd(int fd, const unsigned char 
*old_sha1,
sha1_to_hex(new_sha1),
committer);
if (msglen)
-   len += copy_msg(logrec + len - 1, msg) - 1;
+   len += copy_reflog_msg(logrec + len - 1, msg) - 1;
 
written = len <= maxlen ? write_in_full(fd, logrec, len) : -1;
free(logrec);
-- 
2.6.2

--
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 v8 02/10] verify_refname_available(): new function

2015-11-10 Thread Michael Haggerty
From: Ronnie Sahlberg 

Add a new verify_refname_available() function, which checks whether the
refname is available for use, taking all references (both packed and
loose) into account. This function, unlike the old
verify_refname_available(), has semantics independent of the choice of
reference storage, and can therefore be implemented by alternative
reference backends.

Use the new function in a couple of places.

Signed-off-by: Ronnie Sahlberg 
Signed-off-by: David Turner 
Signed-off-by: Junio C Hamano 
Signed-off-by: Michael Haggerty 
---
 refs.c | 66 --
 1 file changed, 40 insertions(+), 26 deletions(-)

diff --git a/refs.c b/refs.c
index 0617e0c..ddcdf81 100644
--- a/refs.c
+++ b/refs.c
@@ -279,7 +279,7 @@ struct ref_dir {
  * presence of an empty subdirectory does not block the creation of a
  * similarly-named reference.  (The fact that reference names with the
  * same leading components can conflict *with each other* is a
- * separate issue that is regulated by verify_refname_available_dir().)
+ * separate issue that is regulated by verify_refname_available().)
  *
  * Please note that the name field contains the fully-qualified
  * reference (or subdirectory) name.  Space could be saved by only
@@ -897,19 +897,7 @@ static int nonmatching_ref_fn(struct ref_entry *entry, 
void *vdata)
 /*
  * Return 0 if a reference named refname could be created without
  * conflicting with the name of an existing reference in dir.
- * Otherwise, return a negative value and write an explanation to err.
- * If extras is non-NULL, it is a list of additional refnames with
- * which refname is not allowed to conflict. If skip is non-NULL,
- * ignore potential conflicts with refs in skip (e.g., because they
- * are scheduled for deletion in the same operation). Behavior is
- * undefined if the same name is listed in both extras and skip.
- *
- * Two reference names conflict if one of them exactly matches the
- * leading components of the other; e.g., "refs/foo/bar" conflicts
- * with both "refs/foo" and with "refs/foo/bar/baz" but not with
- * "refs/foo/bar" or "refs/foo/barbados".
- *
- * extras and skip must be sorted.
+ * See verify_refname_available for more information.
  */
 static int verify_refname_available_dir(const char *refname,
const struct string_list *extras,
@@ -3120,6 +3108,40 @@ out:
return ret;
 }
 
+/*
+ * Return 0 if a reference named refname could be created without
+ * conflicting with the name of an existing reference. Otherwise,
+ * return a negative value and write an explanation to err. If extras
+ * is non-NULL, it is a list of additional refnames with which refname
+ * is not allowed to conflict. If skip is non-NULL, ignore potential
+ * conflicts with refs in skip (e.g., because they are scheduled for
+ * deletion in the same operation). Behavior is undefined if the same
+ * name is listed in both extras and skip.
+ *
+ * Two reference names conflict if one of them exactly matches the
+ * leading components of the other; e.g., "foo/bar" conflicts with
+ * both "foo" and with "foo/bar/baz" but not with "foo/bar" or
+ * "foo/barbados".
+ *
+ * extras and skip must be sorted.
+ */
+static int verify_refname_available(const char *newname,
+   struct string_list *extras,
+   struct string_list *skip,
+   struct strbuf *err)
+{
+   struct ref_dir *packed_refs = get_packed_refs(&ref_cache);
+   struct ref_dir *loose_refs = get_loose_refs(&ref_cache);
+
+   if (verify_refname_available_dir(newname, extras, skip,
+packed_refs, err) ||
+   verify_refname_available_dir(newname, extras, skip,
+loose_refs, err))
+   return -1;
+
+   return 0;
+}
+
 static int rename_ref_available(const char *oldname, const char *newname)
 {
struct string_list skip = STRING_LIST_INIT_NODUP;
@@ -3127,10 +3149,7 @@ static int rename_ref_available(const char *oldname, 
const char *newname)
int ret;
 
string_list_insert(&skip, oldname);
-   ret = !verify_refname_available_dir(newname, NULL, &skip,
-   get_packed_refs(&ref_cache), &err)
-   && !verify_refname_available_dir(newname, NULL, &skip,
-get_loose_refs(&ref_cache), 
&err);
+   ret = !verify_refname_available(newname, NULL, &skip, &err);
if (!ret)
error("%s", err.buf);
 
@@ -4334,8 +4353,6 @@ static int ref_present(const char *refname,
 int initial_ref_transaction_commit(struct ref_transaction *transaction,
   struct strbuf *err)
 {
-   struct ref_dir *loose_refs = get_loose_refs(&ref_cache);
-   struct ref_dir *packed_refs = get_packed_refs(&ref_cache);
  

[PATCH v8 04/10] pack_if_possible_fn(): use ref_type() instead of is_per_worktree_ref()

2015-11-10 Thread Michael Haggerty
is_per_worktree_ref() will soon be made private, so use the public
interface, ref_type(), in its place. And now that we're using
ref_type(), we can make it clear that we won't pack pseudorefs. This was
the case before, but due to the not-so-obvious reason that this function
is applied to references via the loose reference cache, which only
includes references that live inside "refs/".

Signed-off-by: Michael Haggerty 
---
 refs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/refs.c b/refs.c
index 480de9a..82129f0 100644
--- a/refs.c
+++ b/refs.c
@@ -2671,8 +2671,6 @@ struct pack_refs_cb_data {
struct ref_to_prune *ref_to_prune;
 };
 
-static int is_per_worktree_ref(const char *refname);
-
 /*
  * An each_ref_entry_fn that is run over loose references only.  If
  * the loose reference can be packed, add an entry in the packed ref
@@ -2687,7 +2685,7 @@ static int pack_if_possible_fn(struct ref_entry *entry, 
void *cb_data)
int is_tag_ref = starts_with(entry->name, "refs/tags/");
 
/* Do not pack per-worktree refs: */
-   if (is_per_worktree_ref(entry->name))
+   if (ref_type(entry->name) != REF_TYPE_NORMAL)
return 0;
 
/* ALWAYS pack tags */
-- 
2.6.2

--
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 v8 05/10] refname_is_safe(): improve docstring

2015-11-10 Thread Michael Haggerty
Signed-off-by: Michael Haggerty 
---
 refs.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/refs.c b/refs.c
index 82129f0..f48c58a 100644
--- a/refs.c
+++ b/refs.c
@@ -341,13 +341,17 @@ static struct ref_dir *get_ref_dir(struct ref_entry 
*entry)
 }
 
 /*
- * Check if a refname is safe.
- * For refs that start with "refs/" we consider it safe as long they do
- * not try to resolve to outside of refs/.
+ * Return true iff refname is minimally safe. "Safe" here means that
+ * deleting a loose reference by this name will not do any damage, for
+ * example by causing a file that is not a reference to be deleted.
+ * This function does not check that the reference name is legal; for
+ * that, use check_refname_format().
  *
- * For all other refs we only consider them safe iff they only contain
- * upper case characters and '_' (like "HEAD" AND "MERGE_HEAD", and not like
- * "config").
+ * We consider a refname that starts with "refs/" to be safe as long
+ * as any ".." components that it might contain do not escape "refs/".
+ * Names that do not start with "refs/" are considered safe iff they
+ * consist entirely of upper case characters and '_' (like "HEAD" and
+ * "MERGE_HEAD" but not "config" or "FOO/BAR").
  */
 static int refname_is_safe(const char *refname)
 {
-- 
2.6.2

--
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 v8 09/10] files_log_ref_write: new function

2015-11-10 Thread Michael Haggerty
From: David Turner 

Because HEAD and stash are per-worktree, every refs backend needs to
go through the files backend to write these refs.

So create a new function, files_log_ref_write, and add it to
refs/refs-internal.h. Later, we will use this to handle reflog updates
for per-worktree symbolic refs (HEAD).

Signed-off-by: David Turner 
Signed-off-by: Junio C Hamano 
Signed-off-by: Michael Haggerty 
---
 refs/files-backend.c | 8 
 refs/refs-internal.h | 4 
 2 files changed, 12 insertions(+)

diff --git a/refs/files-backend.c b/refs/files-backend.c
index 14ec506..aaf2639 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -2734,6 +2734,14 @@ static int log_ref_write(const char *refname, const 
unsigned char *old_sha1,
 const unsigned char *new_sha1, const char *msg,
 int flags, struct strbuf *err)
 {
+   return files_log_ref_write(refname, old_sha1, new_sha1, msg, flags,
+  err);
+}
+
+int files_log_ref_write(const char *refname, const unsigned char *old_sha1,
+   const unsigned char *new_sha1, const char *msg,
+   int flags, struct strbuf *err)
+{
struct strbuf sb = STRBUF_INIT;
int ret = log_ref_write_1(refname, old_sha1, new_sha1, msg, &sb, flags,
  err);
diff --git a/refs/refs-internal.h b/refs/refs-internal.h
index 9077c11..7b6c8bc 100644
--- a/refs/refs-internal.h
+++ b/refs/refs-internal.h
@@ -177,4 +177,8 @@ struct ref_transaction {
enum ref_transaction_state state;
 };
 
+int files_log_ref_write(const char *refname, const unsigned char *old_sha1,
+   const unsigned char *new_sha1, const char *msg,
+   int flags, struct strbuf *err);
+
 #endif /* REFS_REFS_INTERNAL_H */
-- 
2.6.2

--
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 v8 06/10] refs/refs-internal.h: new header file

2015-11-10 Thread Michael Haggerty
There are a number of constants, structs, and static functions defined
in refs.c and treated as private to the references module. But we want
to support multiple reference backends within the reference module,
and those backends will need access to some heretofore private
declarations.

We don't want those declarations to be visible to non-refs code, so we
don't want to move them to refs.h. Instead, add a new header file,
refs/refs-internal.h, that is intended to be included only from within
the refs module. Make some functions non-static and move some
declarations (and their corresponding docstrings) from refs.c to this
file.

In a moment we will add more content to the "refs" subdirectory.

Signed-off-by: Michael Haggerty 
---
 refs.c   | 174 +++--
 refs/refs-internal.h | 180 +++
 2 files changed, 189 insertions(+), 165 deletions(-)
 create mode 100644 refs/refs-internal.h

diff --git a/refs.c b/refs.c
index f48c58a..e6b82ee 100644
--- a/refs.c
+++ b/refs.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "lockfile.h"
 #include "refs.h"
+#include "refs/refs-internal.h"
 #include "object.h"
 #include "tag.h"
 #include "dir.h"
@@ -35,41 +36,6 @@ static unsigned char refname_disposition[256] = {
 };
 
 /*
- * Flag passed to lock_ref_sha1_basic() telling it to tolerate broken
- * refs (i.e., because the reference is about to be deleted anyway).
- */
-#define REF_DELETING   0x02
-
-/*
- * Used as a flag in ref_update::flags when a loose ref is being
- * pruned.
- */
-#define REF_ISPRUNING  0x04
-
-/*
- * Used as a flag in ref_update::flags when the reference should be
- * updated to new_sha1.
- */
-#define REF_HAVE_NEW   0x08
-
-/*
- * Used as a flag in ref_update::flags when old_sha1 should be
- * checked.
- */
-#define REF_HAVE_OLD   0x10
-
-/*
- * Used as a flag in ref_update::flags when the lockfile needs to be
- * committed.
- */
-#define REF_NEEDS_COMMIT 0x20
-
-/*
- * 0x40 is REF_FORCE_CREATE_REFLOG, so skip it if you're adding a
- * value to ref_update::flags
- */
-
-/*
  * Try to read one refname component from the front of refname.
  * Return the length of the component found, or -1 if the component is
  * not legal.  It is legal if it is something reasonable to have under
@@ -340,20 +306,7 @@ static struct ref_dir *get_ref_dir(struct ref_entry *entry)
return dir;
 }
 
-/*
- * Return true iff refname is minimally safe. "Safe" here means that
- * deleting a loose reference by this name will not do any damage, for
- * example by causing a file that is not a reference to be deleted.
- * This function does not check that the reference name is legal; for
- * that, use check_refname_format().
- *
- * We consider a refname that starts with "refs/" to be safe as long
- * as any ".." components that it might contain do not escape "refs/".
- * Names that do not start with "refs/" are considered safe iff they
- * consist entirely of upper case characters and '_' (like "HEAD" and
- * "MERGE_HEAD" but not "config" or "FOO/BAR").
- */
-static int refname_is_safe(const char *refname)
+int refname_is_safe(const char *refname)
 {
if (starts_with(refname, "refs/")) {
char *buf;
@@ -1823,39 +1776,7 @@ static int filter_refs(const char *refname, const struct 
object_id *oid,
return filter->fn(refname, oid, flags, filter->cb_data);
 }
 
-enum peel_status {
-   /* object was peeled successfully: */
-   PEEL_PEELED = 0,
-
-   /*
-* object cannot be peeled because the named object (or an
-* object referred to by a tag in the peel chain), does not
-* exist.
-*/
-   PEEL_INVALID = -1,
-
-   /* object cannot be peeled because it is not a tag: */
-   PEEL_NON_TAG = -2,
-
-   /* ref_entry contains no peeled value because it is a symref: */
-   PEEL_IS_SYMREF = -3,
-
-   /*
-* ref_entry cannot be peeled because it is broken (i.e., the
-* symbolic reference cannot even be resolved to an object
-* name):
-*/
-   PEEL_BROKEN = -4
-};
-
-/*
- * Peel the named object; i.e., if the object is a tag, resolve the
- * tag recursively until a non-tag is found.  If successful, store the
- * result to sha1 and return PEEL_PEELED.  If the object is not a tag
- * or is not valid, return PEEL_NON_TAG or PEEL_INVALID, respectively,
- * and leave sha1 unchanged.
- */
-static enum peel_status peel_object(const unsigned char *name, unsigned char 
*sha1)
+enum peel_status peel_object(const unsigned char *name, unsigned char *sha1)
 {
struct object *o = lookup_unknown_object(name);
 
@@ -3110,27 +3031,10 @@ out:
return ret;
 }
 
-/*
- * Return 0 if a reference named refname could be created without
- * conflicting with the name of an existing reference. Otherwise,
- * return a negative value and write an explanation to err. If extras
- * is non-NULL, it is a list of additional refnames with whi

[PATCH v8 01/10] verify_refname_available(): rename function

2015-11-10 Thread Michael Haggerty
From: Ronnie Sahlberg 

Rename verify_refname_available() to verify_refname_available_dir() to
make the old name available for a more general purpose.

Signed-off-by: Ronnie Sahlberg 
Signed-off-by: David Turner 
Signed-off-by: Junio C Hamano 
Signed-off-by: Michael Haggerty 
---
 refs.c | 44 ++--
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/refs.c b/refs.c
index 132eff5..0617e0c 100644
--- a/refs.c
+++ b/refs.c
@@ -279,7 +279,7 @@ struct ref_dir {
  * presence of an empty subdirectory does not block the creation of a
  * similarly-named reference.  (The fact that reference names with the
  * same leading components can conflict *with each other* is a
- * separate issue that is regulated by verify_refname_available().)
+ * separate issue that is regulated by verify_refname_available_dir().)
  *
  * Please note that the name field contains the fully-qualified
  * reference (or subdirectory) name.  Space could be saved by only
@@ -911,11 +911,11 @@ static int nonmatching_ref_fn(struct ref_entry *entry, 
void *vdata)
  *
  * extras and skip must be sorted.
  */
-static int verify_refname_available(const char *refname,
-   const struct string_list *extras,
-   const struct string_list *skip,
-   struct ref_dir *dir,
-   struct strbuf *err)
+static int verify_refname_available_dir(const char *refname,
+   const struct string_list *extras,
+   const struct string_list *skip,
+   struct ref_dir *dir,
+   struct strbuf *err)
 {
const char *slash;
int pos;
@@ -2465,8 +2465,8 @@ static struct ref_lock *lock_ref_sha1_basic(const char 
*refname,
strbuf_git_path(&orig_ref_file, "%s", orig_refname);
if (remove_empty_directories(&orig_ref_file)) {
last_errno = errno;
-   if (!verify_refname_available(orig_refname, extras, 
skip,
- 
get_loose_refs(&ref_cache), err))
+   if (!verify_refname_available_dir(orig_refname, extras, 
skip,
+ 
get_loose_refs(&ref_cache), err))
strbuf_addf(err, "there are still refs under 
'%s'",
orig_refname);
goto error_return;
@@ -2479,8 +2479,8 @@ static struct ref_lock *lock_ref_sha1_basic(const char 
*refname,
if (!refname) {
last_errno = errno;
if (last_errno != ENOTDIR ||
-   !verify_refname_available(orig_refname, extras, skip,
- get_loose_refs(&ref_cache), err))
+   !verify_refname_available_dir(orig_refname, extras, skip,
+ get_loose_refs(&ref_cache), 
err))
strbuf_addf(err, "unable to resolve reference %s: %s",
orig_refname, strerror(last_errno));
 
@@ -2493,8 +2493,8 @@ static struct ref_lock *lock_ref_sha1_basic(const char 
*refname,
 * our refname.
 */
if (is_null_oid(&lock->old_oid) &&
-   verify_refname_available(refname, extras, skip,
-get_packed_refs(&ref_cache), err)) {
+   verify_refname_available_dir(refname, extras, skip,
+get_packed_refs(&ref_cache), err)) {
last_errno = ENOTDIR;
goto error_return;
}
@@ -3127,10 +3127,10 @@ static int rename_ref_available(const char *oldname, 
const char *newname)
int ret;
 
string_list_insert(&skip, oldname);
-   ret = !verify_refname_available(newname, NULL, &skip,
-   get_packed_refs(&ref_cache), &err)
-   && !verify_refname_available(newname, NULL, &skip,
-get_loose_refs(&ref_cache), &err);
+   ret = !verify_refname_available_dir(newname, NULL, &skip,
+   get_packed_refs(&ref_cache), &err)
+   && !verify_refname_available_dir(newname, NULL, &skip,
+get_loose_refs(&ref_cache), 
&err);
if (!ret)
error("%s", err.buf);
 
@@ -4376,12 +4376,12 @@ int initial_ref_transaction_commit(struct 
ref_transaction *transaction,
if ((update->flags & REF_HAVE_OLD) &&
!is_null_sha1(update->old_sha1))
die("BUG: initial ref transaction with old_sha1 set");
-   if (verify_refname_available(update->refname,
-  

[PATCH v8 08/10] initdb: make safe_create_dir public

2015-11-10 Thread Michael Haggerty
From: David Turner 

Soon we will want to create initdb functions for ref backends, and
code from initdb that calls this function needs to move into the files
backend. So this function needs to be public.

Signed-off-by: David Turner 
Signed-off-by: Junio C Hamano 
Signed-off-by: Michael Haggerty 
---
 builtin/init-db.c | 12 
 cache.h   |  8 
 path.c| 12 
 3 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/builtin/init-db.c b/builtin/init-db.c
index f59f407..07229d6 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -24,18 +24,6 @@ static int init_shared_repository = -1;
 static const char *init_db_template_dir;
 static const char *git_link;
 
-static void safe_create_dir(const char *dir, int share)
-{
-   if (mkdir(dir, 0777) < 0) {
-   if (errno != EEXIST) {
-   perror(dir);
-   exit(1);
-   }
-   }
-   else if (share && adjust_shared_perm(dir))
-   die(_("Could not make %s writable by group"), dir);
-}
-
 static void copy_templates_1(struct strbuf *path, struct strbuf *template,
 DIR *dir)
 {
diff --git a/cache.h b/cache.h
index 9a905a8..0f9808c 100644
--- a/cache.h
+++ b/cache.h
@@ -1737,4 +1737,12 @@ void stat_validity_update(struct stat_validity *sv, int 
fd);
 int versioncmp(const char *s1, const char *s2);
 void sleep_millisec(int millisec);
 
+/*
+ * Create a directory and (if share is nonzero) adjust its permissions
+ * according to the shared_repository setting. Only use this for
+ * directories under $GIT_DIR.  Don't use it for working tree
+ * directories.
+ */
+void safe_create_dir(const char *dir, int share);
+
 #endif /* CACHE_H */
diff --git a/path.c b/path.c
index 212695a..9e0283c 100644
--- a/path.c
+++ b/path.c
@@ -723,6 +723,18 @@ int adjust_shared_perm(const char *path)
return 0;
 }
 
+void safe_create_dir(const char *dir, int share)
+{
+   if (mkdir(dir, 0777) < 0) {
+   if (errno != EEXIST) {
+   perror(dir);
+   exit(1);
+   }
+   }
+   else if (share && adjust_shared_perm(dir))
+   die(_("Could not make %s writable by group"), dir);
+}
+
 static int have_same_root(const char *path1, const char *path2)
 {
int is_abs1, is_abs2;
-- 
2.6.2

--
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 v8 10/10] refs: break out ref conflict checks

2015-11-10 Thread Michael Haggerty
From: David Turner 

Create new function find_descendant_ref, to hold one of the ref
conflict checks used in verify_refname_available. Multiple backends
will need this function, so move it to the common code.

Also move rename_ref_available to the common code, because alternate
backends might need it and it has no files-backend-specific code.

Signed-off-by: David Turner 
Signed-off-by: Junio C Hamano 
Signed-off-by: Michael Haggerty 
---
 refs.c   | 44 
 refs/files-backend.c | 49 +++--
 refs/refs-internal.h | 16 
 3 files changed, 67 insertions(+), 42 deletions(-)

diff --git a/refs.c b/refs.c
index 1620a53..ad883ec 100644
--- a/refs.c
+++ b/refs.c
@@ -1029,3 +1029,47 @@ int ref_is_hidden(const char *refname)
}
return 0;
 }
+
+const char *find_descendant_ref(const char *dirname,
+   const struct string_list *extras,
+   const struct string_list *skip)
+{
+   int pos;
+
+   if (!extras)
+   return NULL;
+
+   /*
+* Look at the place where dirname would be inserted into
+* extras. If there is an entry at that position that starts
+* with dirname (remember, dirname includes the trailing
+* slash) and is not in skip, then we have a conflict.
+*/
+   for (pos = string_list_find_insert_index(extras, dirname, 0);
+pos < extras->nr; pos++) {
+   const char *extra_refname = extras->items[pos].string;
+
+   if (!starts_with(extra_refname, dirname))
+   break;
+
+   if (!skip || !string_list_has_string(skip, extra_refname))
+   return extra_refname;
+   }
+   return NULL;
+}
+
+int rename_ref_available(const char *oldname, const char *newname)
+{
+   struct string_list skip = STRING_LIST_INIT_NODUP;
+   struct strbuf err = STRBUF_INIT;
+   int ret;
+
+   string_list_insert(&skip, oldname);
+   ret = !verify_refname_available(newname, NULL, &skip, &err);
+   if (!ret)
+   error("%s", err.buf);
+
+   string_list_clear(&skip, 0);
+   strbuf_release(&err);
+   return ret;
+}
diff --git a/refs/files-backend.c b/refs/files-backend.c
index aaf2639..4db3e36 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -728,6 +728,7 @@ static int verify_refname_available_dir(const char *refname,
struct strbuf *err)
 {
const char *slash;
+   const char *extra_refname;
int pos;
struct strbuf dirname = STRBUF_INIT;
int ret = -1;
@@ -833,32 +834,12 @@ static int verify_refname_available_dir(const char 
*refname,
}
}
 
-   if (extras) {
-   /*
-* Check for entries in extras that start with
-* "$refname/". We do that by looking for the place
-* where "$refname/" would be inserted in extras. If
-* there is an entry at that position that starts with
-* "$refname/" and is not in skip, then we have a
-* conflict.
-*/
-   for (pos = string_list_find_insert_index(extras, dirname.buf, 
0);
-pos < extras->nr; pos++) {
-   const char *extra_refname = extras->items[pos].string;
-
-   if (!starts_with(extra_refname, dirname.buf))
-   break;
-
-   if (!skip || !string_list_has_string(skip, 
extra_refname)) {
-   strbuf_addf(err, "cannot process '%s' and '%s' 
at the same time",
-   refname, extra_refname);
-   goto cleanup;
-   }
-   }
-   }
-
-   /* No conflicts were found */
-   ret = 0;
+   extra_refname = find_descendant_ref(dirname.buf, extras, skip);
+   if (extra_refname)
+   strbuf_addf(err, "cannot process '%s' and '%s' at the same 
time",
+   refname, extra_refname);
+   else
+   ret = 0;
 
 cleanup:
strbuf_release(&dirname);
@@ -2473,22 +2454,6 @@ int verify_refname_available(const char *newname,
return 0;
 }
 
-static int rename_ref_available(const char *oldname, const char *newname)
-{
-   struct string_list skip = STRING_LIST_INIT_NODUP;
-   struct strbuf err = STRBUF_INIT;
-   int ret;
-
-   string_list_insert(&skip, oldname);
-   ret = !verify_refname_available(newname, NULL, &skip, &err);
-   if (!ret)
-   error("%s", err.buf);
-
-   string_list_clear(&skip, 0);
-   strbuf_release(&err);
-   return ret;
-}
-
 static int write_ref_to_lockfile(struct ref_lock *lock,
 const unsigned char *sha1, struct s

[PATCH v8 00/10] refs backend pre-vtable

2015-11-10 Thread Michael Haggerty
Another re-roll of this patch series, to address the comments of
Ramsay Jones (thanks!) about v7 [1].

This version has the following changes compared to v7:

* Drop "refs: make is_branch public" patch. This was already done
  quite a while ago:

  e7e0f26 refs.c: add a public is_branch function (2014-07-15)

* Instead of having refs-internal.h include refs.h, have the "*.c"
  files include both header files.

* Remove some unneeded includes from refs/files-backend.c.

Since patch 01/11 of v7 was omitted, the patches in this version are
numbered differently. In particular, it is now patches 01 through 07
that form the core of this patch series. The last three patches can
easily be postponed if that will speed the progress of the first
seven.

These patches are also available from my GitHub fork [2] as branch
"refs-backend-pre-vtable".

Michael

[1] http://article.gmane.org/gmane.comp.version-control.git/281057
[2] https://github.com/mhagger/git

David Turner (4):
  copy_msg(): rename to copy_reflog_msg()
  initdb: make safe_create_dir public
  files_log_ref_write: new function
  refs: break out ref conflict checks

Michael Haggerty (4):
  pack_if_possible_fn(): use ref_type() instead of is_per_worktree_ref()
  refname_is_safe(): improve docstring
  refs/refs-internal.h: new header file
  refs: split filesystem-based refs code into a new file

Ronnie Sahlberg (2):
  verify_refname_available(): rename function
  verify_refname_available(): new function

 Makefile   |3 +-
 builtin/init-db.c  |   12 -
 cache.h|8 +
 path.c |   12 +
 refs.c | 3709 +---
 refs.c => refs/files-backend.c | 1286 +-
 refs/refs-internal.h   |  200 +++
 7 files changed, 311 insertions(+), 4919 deletions(-)
 copy refs.c => refs/files-backend.c (75%)
 create mode 100644 refs/refs-internal.h

-- 
2.6.2

--
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: gitk fails to start after upgrading to 2.6.3 (cannot load translation)

2015-11-10 Thread Dennis Kaarsemaker
On di, 2015-11-10 at 10:48 +0100, Peter Krefting wrote:
> Hi!
> 
> After upgrading Git to 2.6.3 (from 2.5.0), gitk refuses to start when
> trying to load the Swedish translation if I pass it a commit range:

Hi Peter,

This bug has been reported a few times already and a fix will be in git
2.7.
-- 
Dennis Kaarsemaker
www.kaarsemaker.net


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


gitk fails to start after upgrading to 2.6.3 (cannot load translation)

2015-11-10 Thread Peter Krefting

Hi!

After upgrading Git to 2.6.3 (from 2.5.0), gitk refuses to start when 
trying to load the Swedish translation if I pass it a commit range:


  $ gitk v2.5.0..v2.6.3
  Error in startup script: bad menu entry index "Ă„ndra vy..."
  while executing
  ".bar.view entryconf [mca "Edit view..."] -state normal"
  invoked from within
"if {$cmdline_files ne {} || $revtreeargs ne {} || $revtreeargscmd ne {}} {
# create a view for the files/dirs specified on the command line
se..."
(file "/usr/local/bin/gitk" line 12442)

If I start it without any parameters, it does start up, but the main 
menu is untranslated.


The translation for this entry is defined in gitk-git/po/sv.po line 135 
and hasn't changed since 2008, even if the sv.po file does have a few 
updates since the previous version in some other places.


--
\\// Peter - http://www.softwolves.pp.se/
--
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