[PATCH v6 04/28] revert/cherry-pick: add --skip option

2013-08-30 Thread Felipe Contreras
Akin to 'am --skip' and 'rebase --skip'.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 Documentation/git-cherry-pick.txt |  1 +
 Documentation/git-revert.txt  |  1 +
 Documentation/sequencer.txt   |  3 +++
 builtin/revert.c  |  6 ++
 sequencer.c   | 24 
 sequencer.h   |  3 ++-
 t/t3510-cherry-pick-sequence.sh   | 12 
 7 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/Documentation/git-cherry-pick.txt 
b/Documentation/git-cherry-pick.txt
index da0bd81..d95c63c 100644
--- a/Documentation/git-cherry-pick.txt
+++ b/Documentation/git-cherry-pick.txt
@@ -10,6 +10,7 @@ SYNOPSIS
 [verse]
 'git cherry-pick' [-q] [--edit] [-n] [-m parent-number] [-s] [-x] [--ff] 
commit...
 'git cherry-pick' --continue
+'git cherry-pick' --skip
 'git cherry-pick' --quit
 'git cherry-pick' --abort
 
diff --git a/Documentation/git-revert.txt b/Documentation/git-revert.txt
index 98a8e7a..52e146e 100644
--- a/Documentation/git-revert.txt
+++ b/Documentation/git-revert.txt
@@ -10,6 +10,7 @@ SYNOPSIS
 [verse]
 'git revert' [-q] [--[no-]edit] [-n] [-m parent-number] [-s] commit...
 'git revert' --continue
+'git revert' --skip
 'git revert' --quit
 'git revert' --abort
 
diff --git a/Documentation/sequencer.txt b/Documentation/sequencer.txt
index 5747f44..df2d355 100644
--- a/Documentation/sequencer.txt
+++ b/Documentation/sequencer.txt
@@ -3,6 +3,9 @@
'.git/sequencer'.  Can be used to continue after resolving
conflicts in a failed cherry-pick or revert.
 
+--skip::
+   Skip the current commit, and then continue.
+
 --quit::
Forget about the current operation in progress.  Can be used
to clear the sequencer state after a failed cherry-pick or
diff --git a/builtin/revert.c b/builtin/revert.c
index 7a7fde6..d3ae2c4 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -101,11 +101,13 @@ static void parse_args(int argc, const char **argv, 
struct replay_opts *opts)
int remove_state = 0;
int contin = 0;
int rollback = 0;
+   int skip = 0;
struct option options[] = {
OPT__QUIET(opts-quiet, N_(suppress progress reporting)),
OPT_BOOLEAN(0, quit, remove_state, N_(end revert or 
cherry-pick sequence)),
OPT_BOOLEAN(0, continue, contin, N_(resume revert or 
cherry-pick sequence)),
OPT_BOOLEAN(0, abort, rollback, N_(cancel revert or 
cherry-pick sequence)),
+   OPT_BOOLEAN(0, skip, skip, N_(skip current commit in the 
sequence)),
OPT_BOOLEAN('n', no-commit, opts-no_commit, N_(don't 
automatically commit)),
OPT_BOOLEAN('e', edit, opts-edit, N_(edit the commit 
message)),
OPT_NOOP_NOARG('r', NULL),
@@ -166,6 +168,8 @@ static void parse_args(int argc, const char **argv, struct 
replay_opts *opts)
opts-subcommand = REPLAY_CONTINUE;
else if (rollback)
opts-subcommand = REPLAY_ROLLBACK;
+   else if (skip)
+   opts-subcommand = REPLAY_SKIP;
else
opts-subcommand = REPLAY_NONE;
 
@@ -176,6 +180,8 @@ static void parse_args(int argc, const char **argv, struct 
replay_opts *opts)
this_operation = --quit;
else if (opts-subcommand == REPLAY_CONTINUE)
this_operation = --continue;
+   else if (opts-subcommand == REPLAY_SKIP)
+   this_operation = --skip;
else {
assert(opts-subcommand == REPLAY_ROLLBACK);
this_operation = --abort;
diff --git a/sequencer.c b/sequencer.c
index d6199e4..d0e65de 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1056,6 +1056,28 @@ static int sequencer_continue(struct replay_opts *opts)
return pick_commits(todo_list, opts);
 }
 
+static int sequencer_skip(struct replay_opts *opts)
+{
+   const char *argv[4]; /* reset --hard HEAD + NULL */
+   struct string_list merge_rr = STRING_LIST_INIT_DUP;
+   int ret;
+
+   if (setup_rerere(merge_rr, 0) = 0) {
+   rerere_clear(merge_rr);
+   string_list_clear(merge_rr, 1);
+   }
+
+   argv[0] = reset;
+   argv[1] = --hard;
+   argv[2] = HEAD;
+   argv[3] = NULL;
+   ret = run_command_v_opt(argv, RUN_GIT_CMD);
+   if (ret)
+   return ret;
+
+   return sequencer_continue(opts);
+}
+
 static int single_pick(struct commit *cmit, struct replay_opts *opts)
 {
setenv(GIT_REFLOG_ACTION, action_name(opts), 0);
@@ -1086,6 +1108,8 @@ int sequencer_pick_revisions(struct replay_opts *opts)
return sequencer_rollback(opts);
if (opts-subcommand == REPLAY_CONTINUE)
return sequencer_continue(opts);
+   if (opts-subcommand == REPLAY_SKIP)
+   return sequencer_skip(opts);
 
for (i = 0; i  

[PATCH v6 00/28] Massive improvents to rebase and cherry-pick

2013-08-30 Thread Felipe Contreras
Hi,

These are improvements to 'git rebase' by using a much improved 'git
cherry-pick'.

A new rewrite.c helper is added, and builtin/commit updated to use
that.

A new git-rebase--cherypick mode is added, and it replaces git-rebase--am and
git-rebase--merge.

Felipe Contreras (28):
  cherry-pick: don't barf when there's nothing to do
  cherry-pick: add --skip-empty option
  revert/cherry-pick: add --quiet option
  revert/cherry-pick: add --skip option
  builtin: add rewrite helper
  cherry-pick: store rewritten commits
  cherry-pick: don't store skipped commit
  builtin: move run_rewrite_hook() to rewrite.c
  builtin: rewrite: add copy_rewrite_notes()
  cherry-pick: add --action-name option
  cherry-pick: copy notes and run hooks
  cherry-pick: remember rerere-autoupdate
  rebase: split the cherry-pick stuff
  rebase: cherry-pick: fix mode storage
  rebase: cherry-pick: fix sequence continuation
  rebase: cherry-pick: fix abort of cherry mode
  rebase: cherry-pick: fix command invocations
  rebase: cherry-pick: fix status messages
  rebase: cherry-pick: automatically commit stage
  rebase: cherry-pick: set correct action-name
  rebase: trivial cleanup
  t: rebase-autostash: fix setup
  sequencer: store progress information
  prompt: parse cherry-pick rebase mode
  rebase: use 'cherrypick' mode instead of 'am'
  rebase: cherry-pick: add merge options
  rebase: remove merge mode
  rebase: cherry-pick: add copyright

 .gitignore |   2 +-
 Documentation/config.txt   |   9 +-
 Documentation/git-cherry-pick.txt  |  10 ++-
 Documentation/git-revert.txt   |   7 +-
 Documentation/githooks.txt |   8 +-
 Documentation/sequencer.txt|   3 +
 Makefile   |   4 +-
 builtin/commit.c   |  46 ++
 builtin/revert.c   |  17 
 contrib/completion/git-prompt.sh   |  16 ++--
 git-rebase--am.sh  |  12 +--
 git-rebase--cherrypick.sh  |  66 ++
 git-rebase--interactive.sh |   6 +-
 git-rebase--merge.sh   | 151 -
 git-rebase.sh  |  16 ++--
 rewrite.c  | 122 ++
 rewrite.h  |  20 +
 sequencer.c| 124 +--
 sequencer.h|   8 +-
 t/t3406-rebase-message.sh  |  14 +--
 t/t3407-rebase-abort.sh|   2 +-
 t/t3420-rebase-autostash.sh| 107 ---
 t/t3425-rebase-topology-merges.sh  |  15 ++--
 t/t3508-cherry-pick-many-commits.sh|  13 +++
 t/t3510-cherry-pick-sequence.sh|  14 ++-
 t/t5520-pull.sh|   2 +-
 t/t9106-git-svn-commit-diff-clobber.sh |   2 +-
 t/t9903-bash-prompt.sh |   2 +-
 28 files changed, 496 insertions(+), 322 deletions(-)
 create mode 100644 git-rebase--cherrypick.sh
 delete mode 100644 git-rebase--merge.sh
 create mode 100644 rewrite.c
 create mode 100644 rewrite.h

-- 
1.8.4-fc

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


[PATCH v6 01/28] cherry-pick: don't barf when there's nothing to do

2013-08-30 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 sequencer.c | 2 +-
 t/t3510-cherry-pick-sequence.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sequencer.c b/sequencer.c
index 351548f..a962b33 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -661,7 +661,7 @@ static void prepare_revs(struct replay_opts *opts)
die(_(revision walk setup failed));
 
if (!opts-revs-commits)
-   die(_(empty commit set passed));
+   error(_(empty commit set passed));
 }
 
 static void read_and_refresh_cache(struct replay_opts *opts)
diff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh
index 7b7a89d..33c5512 100755
--- a/t/t3510-cherry-pick-sequence.sh
+++ b/t/t3510-cherry-pick-sequence.sh
@@ -472,7 +472,7 @@ test_expect_success 'malformed instruction sheet 2' '
 
 test_expect_success 'empty commit set' '
pristine_detach initial 
-   test_expect_code 128 git cherry-pick base..base
+   git cherry-pick base..base
 '
 
 test_expect_success 'malformed instruction sheet 3' '
-- 
1.8.4-fc

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


[PATCH v6 02/28] cherry-pick: add --skip-empty option

2013-08-30 Thread Felipe Contreras
Pretty much what it says on the tin.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 Documentation/git-cherry-pick.txt   |  3 +++
 builtin/revert.c|  8 
 sequencer.c |  6 ++
 sequencer.h |  1 +
 t/t3508-cherry-pick-many-commits.sh | 13 +
 5 files changed, 31 insertions(+)

diff --git a/Documentation/git-cherry-pick.txt 
b/Documentation/git-cherry-pick.txt
index c205d23..fccd936 100644
--- a/Documentation/git-cherry-pick.txt
+++ b/Documentation/git-cherry-pick.txt
@@ -129,6 +129,9 @@ effect to your index in a row.
redundant commits are ignored.  This option overrides that behavior and
creates an empty commit object.  Implies `--allow-empty`.
 
+--skip-empty::
+   Instead of failing, skip commits that are or become empty.
+
 --strategy=strategy::
Use the given merge strategy.  Should only be used once.
See the MERGE STRATEGIES section in linkgit:git-merge[1]
diff --git a/builtin/revert.c b/builtin/revert.c
index 1d2648b..6e7cb2a 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -120,6 +120,7 @@ static void parse_args(int argc, const char **argv, struct 
replay_opts *opts)
OPT_END(),
OPT_END(),
OPT_END(),
+   OPT_END(),
};
 
if (opts-action == REPLAY_PICK) {
@@ -129,6 +130,7 @@ static void parse_args(int argc, const char **argv, struct 
replay_opts *opts)
OPT_BOOLEAN(0, allow-empty, opts-allow_empty, 
N_(preserve initially empty commits)),
OPT_BOOLEAN(0, allow-empty-message, 
opts-allow_empty_message, N_(allow commits with empty messages)),
OPT_BOOLEAN(0, keep-redundant-commits, 
opts-keep_redundant_commits, N_(keep redundant, empty commits)),
+   OPT_BOOLEAN(0, skip-empty, opts-skip_empty, 
N_(skip empty commits)),
OPT_END(),
};
if (parse_options_concat(options, ARRAY_SIZE(options), 
cp_extra))
@@ -146,6 +148,12 @@ static void parse_args(int argc, const char **argv, struct 
replay_opts *opts)
--abort, rollback,
NULL);
 
+   verify_opt_mutually_compatible(me,
+   --allow-empty, opts-allow_empty,
+   --skip-empty, opts-skip_empty,
+   --keep-redundant-commits, 
opts-keep_redundant_commits,
+   NULL);
+
/* implies allow_empty */
if (opts-keep_redundant_commits)
opts-allow_empty = 1;
diff --git a/sequencer.c b/sequencer.c
index a962b33..c387828 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -633,6 +633,12 @@ static int do_pick_commit(struct commit *commit, struct 
replay_opts *opts)
goto leave;
}
 
+   if (opts-skip_empty  is_index_unchanged() == 1) {
+   warning(_(skipping %s... %s),
+   find_unique_abbrev(commit-object.sha1, DEFAULT_ABBREV),
+   msg.subject);
+   goto leave;
+   }
allow = allow_empty(opts, commit);
if (allow  0) {
res = allow;
diff --git a/sequencer.h b/sequencer.h
index 1fc22dc..3b04844 100644
--- a/sequencer.h
+++ b/sequencer.h
@@ -34,6 +34,7 @@ struct replay_opts {
int allow_empty;
int allow_empty_message;
int keep_redundant_commits;
+   int skip_empty;
 
int mainline;
 
diff --git a/t/t3508-cherry-pick-many-commits.sh 
b/t/t3508-cherry-pick-many-commits.sh
index 19c99d7..3dc19c6 100755
--- a/t/t3508-cherry-pick-many-commits.sh
+++ b/t/t3508-cherry-pick-many-commits.sh
@@ -187,4 +187,17 @@ test_expect_success 'cherry-pick --stdin works' '
check_head_differs_from fourth
 '
 
+test_expect_success 'cherry-pick skip empty' '
+   git clean -fxd 
+   git checkout -b empty fourth 
+   git commit --allow-empty -m empty 
+   test_commit ontop 
+   git checkout -f master 
+   git reset --hard fourth 
+   git cherry-pick --skip-empty fourth..empty 
+   echo ontop  expected 
+   git log --format=%s fourth..HEAD  actual
+   test_cmp expected actual
+'
+
 test_done
-- 
1.8.4-fc

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


[PATCH v6 03/28] revert/cherry-pick: add --quiet option

2013-08-30 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 Documentation/git-cherry-pick.txt |  6 +-
 Documentation/git-revert.txt  |  6 +-
 builtin/revert.c  |  1 +
 sequencer.c   | 11 +++
 sequencer.h   |  1 +
 5 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/Documentation/git-cherry-pick.txt 
b/Documentation/git-cherry-pick.txt
index fccd936..da0bd81 100644
--- a/Documentation/git-cherry-pick.txt
+++ b/Documentation/git-cherry-pick.txt
@@ -8,7 +8,7 @@ git-cherry-pick - Apply the changes introduced by some existing 
commits
 SYNOPSIS
 
 [verse]
-'git cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] [--ff] commit...
+'git cherry-pick' [-q] [--edit] [-n] [-m parent-number] [-s] [-x] [--ff] 
commit...
 'git cherry-pick' --continue
 'git cherry-pick' --quit
 'git cherry-pick' --abort
@@ -51,6 +51,10 @@ OPTIONS
feed all commit... arguments to a single revision walk
(see a later example that uses 'maint master..next').
 
+-q::
+--quiet::
+   Quiet, suppress feedback messages.
+
 -e::
 --edit::
With this option, 'git cherry-pick' will let you edit the commit
diff --git a/Documentation/git-revert.txt b/Documentation/git-revert.txt
index f79c9d8..98a8e7a 100644
--- a/Documentation/git-revert.txt
+++ b/Documentation/git-revert.txt
@@ -8,7 +8,7 @@ git-revert - Revert some existing commits
 SYNOPSIS
 
 [verse]
-'git revert' [--[no-]edit] [-n] [-m parent-number] [-s] commit...
+'git revert' [-q] [--[no-]edit] [-n] [-m parent-number] [-s] commit...
 'git revert' --continue
 'git revert' --quit
 'git revert' --abort
@@ -40,6 +40,10 @@ OPTIONS
default, see linkgit:git-rev-list[1] and its '--no-walk'
option.
 
+-q::
+--quiet::
+   Quiet, suppress feedback messages.
+
 -e::
 --edit::
With this option, 'git revert' will let you edit the commit
diff --git a/builtin/revert.c b/builtin/revert.c
index 6e7cb2a..7a7fde6 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -102,6 +102,7 @@ static void parse_args(int argc, const char **argv, struct 
replay_opts *opts)
int contin = 0;
int rollback = 0;
struct option options[] = {
+   OPT__QUIET(opts-quiet, N_(suppress progress reporting)),
OPT_BOOLEAN(0, quit, remove_state, N_(end revert or 
cherry-pick sequence)),
OPT_BOOLEAN(0, continue, contin, N_(resume revert or 
cherry-pick sequence)),
OPT_BOOLEAN(0, abort, rollback, N_(cancel revert or 
cherry-pick sequence)),
diff --git a/sequencer.c b/sequencer.c
index c387828..d6199e4 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -395,6 +395,8 @@ static int run_git_commit(const char *defmsg, struct 
replay_opts *opts,
argv_array_init(array);
argv_array_push(array, commit);
argv_array_push(array, -n);
+   if (opts-quiet)
+   argv_array_push(array, -q);
 
if (opts-signoff)
argv_array_push(array, -s);
@@ -634,9 +636,10 @@ static int do_pick_commit(struct commit *commit, struct 
replay_opts *opts)
}
 
if (opts-skip_empty  is_index_unchanged() == 1) {
-   warning(_(skipping %s... %s),
-   find_unique_abbrev(commit-object.sha1, DEFAULT_ABBREV),
-   msg.subject);
+   if (!opts-quiet)
+   warning(_(skipping %s... %s),
+   find_unique_abbrev(commit-object.sha1, 
DEFAULT_ABBREV),
+   msg.subject);
goto leave;
}
allow = allow_empty(opts, commit);
@@ -666,7 +669,7 @@ static void prepare_revs(struct replay_opts *opts)
if (prepare_revision_walk(opts-revs))
die(_(revision walk setup failed));
 
-   if (!opts-revs-commits)
+   if (!opts-revs-commits  !opts-quiet)
error(_(empty commit set passed));
 }
 
diff --git a/sequencer.h b/sequencer.h
index 3b04844..d37c003 100644
--- a/sequencer.h
+++ b/sequencer.h
@@ -35,6 +35,7 @@ struct replay_opts {
int allow_empty_message;
int keep_redundant_commits;
int skip_empty;
+   int quiet;
 
int mainline;
 
-- 
1.8.4-fc

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


[PATCH v6 05/28] builtin: add rewrite helper

2013-08-30 Thread Felipe Contreras
So that we can load and store rewrites, as well as other operations on a
list of rewritten commits.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 Makefile  |  2 ++
 rewrite.c | 71 +++
 rewrite.h | 18 
 3 files changed, 91 insertions(+)
 create mode 100644 rewrite.c
 create mode 100644 rewrite.h

diff --git a/Makefile b/Makefile
index 3588ca1..9396d57 100644
--- a/Makefile
+++ b/Makefile
@@ -716,6 +716,7 @@ LIB_H += remote.h
 LIB_H += rerere.h
 LIB_H += resolve-undo.h
 LIB_H += revision.h
+LIB_H += rewrite.h
 LIB_H += run-command.h
 LIB_H += send-pack.h
 LIB_H += sequencer.h
@@ -860,6 +861,7 @@ LIB_OBJS += replace_object.o
 LIB_OBJS += rerere.o
 LIB_OBJS += resolve-undo.o
 LIB_OBJS += revision.o
+LIB_OBJS += rewrite.o
 LIB_OBJS += run-command.o
 LIB_OBJS += send-pack.o
 LIB_OBJS += sequencer.o
diff --git a/rewrite.c b/rewrite.c
new file mode 100644
index 000..2793688
--- /dev/null
+++ b/rewrite.c
@@ -0,0 +1,71 @@
+#include cache.h
+#include rewrite.h
+
+void add_rewritten(struct rewritten *list, unsigned char *from, unsigned char 
*to)
+{
+   struct rewritten_item *item;
+   ALLOC_GROW(list-items, list-nr, list-alloc);
+   item = list-items[list-nr];
+   hashcpy(item-from, from);
+   hashcpy(item-to, to);
+   list-nr++;
+}
+
+int store_rewritten(struct rewritten *list, const char *file)
+{
+   static struct lock_file lock;
+   struct strbuf buf = STRBUF_INIT;
+   int fd, i, ret = 0;
+
+   fd = hold_lock_file_for_update(lock, file, LOCK_DIE_ON_ERROR);
+   for (i = 0; i  list-nr; i++) {
+   struct rewritten_item *item = list-items[i];
+   strbuf_addf(buf, %s %s\n, sha1_to_hex(item-from), 
sha1_to_hex(item-to));
+   }
+   if (write_in_full(fd, buf.buf, buf.len)  0) {
+   error(_(Could not write to %s), file);
+   ret = 1;
+   goto leave;
+   }
+   if (commit_lock_file(lock)  0) {
+   error(_(Error wrapping up %s.), file);
+   ret = 1;
+   goto leave;
+   }
+leave:
+   strbuf_release(buf);
+   return ret;
+}
+
+void load_rewritten(struct rewritten *list, const char *file)
+{
+   struct strbuf buf = STRBUF_INIT;
+   char *p;
+   int fd;
+
+   fd = open(file, O_RDONLY);
+   if (fd  0)
+   return;
+   if (strbuf_read(buf, fd, 0)  0) {
+   close(fd);
+   strbuf_release(buf);
+   return;
+   }
+   close(fd);
+
+   for (p = buf.buf; *p;) {
+   unsigned char from[20];
+   unsigned char to[20];
+   char *eol = strchrnul(p, '\n');
+   if (eol - p != 81)
+   /* wrong size */
+   break;
+   if (get_sha1_hex(p, from))
+   break;
+   if (get_sha1_hex(p + 41, to))
+   break;
+   add_rewritten(list, from, to);
+   p = *eol ? eol + 1 : eol;
+   }
+   strbuf_release(buf);
+}
diff --git a/rewrite.h b/rewrite.h
new file mode 100644
index 000..09e7222
--- /dev/null
+++ b/rewrite.h
@@ -0,0 +1,18 @@
+#ifndef REWRITE_H
+#define REWRITE_H
+
+struct rewritten_item {
+   unsigned char from[20];
+   unsigned char to[20];
+};
+
+struct rewritten {
+   struct rewritten_item *items;
+   unsigned int nr, alloc;
+};
+
+void add_rewritten(struct rewritten *list, unsigned char *from, unsigned char 
*to);
+int store_rewritten(struct rewritten *list, const char *file);
+void load_rewritten(struct rewritten *list, const char *file);
+
+#endif
-- 
1.8.4-fc

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


[PATCH v6 08/28] builtin: move run_rewrite_hook() to rewrite.c

2013-08-30 Thread Felipe Contreras
And use struct rewrite.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 builtin/commit.c | 38 +-
 rewrite.c| 32 
 rewrite.h|  1 +
 3 files changed, 38 insertions(+), 33 deletions(-)

diff --git a/builtin/commit.c b/builtin/commit.c
index 10acc53..7bfe9d0 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -30,6 +30,7 @@
 #include column.h
 #include sequencer.h
 #include notes-utils.h
+#include rewrite.h
 
 static const char * const builtin_commit_usage[] = {
N_(git commit [options] [--] pathspec...),
@@ -1386,38 +1387,6 @@ static int git_commit_config(const char *k, const char 
*v, void *cb)
return git_status_config(k, v, s);
 }
 
-static int run_rewrite_hook(const unsigned char *oldsha1,
-   const unsigned char *newsha1)
-{
-   /* oldsha1 SP newsha1 LF NUL */
-   static char buf[2*40 + 3];
-   struct child_process proc;
-   const char *argv[3];
-   int code;
-   size_t n;
-
-   argv[0] = find_hook(post-rewrite);
-   if (!argv[0])
-   return 0;
-
-   argv[1] = amend;
-   argv[2] = NULL;
-
-   memset(proc, 0, sizeof(proc));
-   proc.argv = argv;
-   proc.in = -1;
-   proc.stdout_to_stderr = 1;
-
-   code = start_command(proc);
-   if (code)
-   return code;
-   n = snprintf(buf, sizeof(buf), %s %s\n,
-sha1_to_hex(oldsha1), sha1_to_hex(newsha1));
-   write_in_full(proc.in, buf, n);
-   close(proc.in);
-   return finish_command(proc);
-}
-
 int cmd_commit(int argc, const char **argv, const char *prefix)
 {
static struct wt_status s;
@@ -1653,13 +1622,16 @@ int cmd_commit(int argc, const char **argv, const char 
*prefix)
run_hook(get_index_file(), post-commit, NULL);
if (amend  !no_post_rewrite) {
struct notes_rewrite_cfg *cfg;
+   struct rewritten rewrite;
+   memset(rewrite, 0, sizeof(rewrite));
cfg = init_copy_notes_for_rewrite(amend);
if (cfg) {
/* we are amending, so current_head is not NULL */
copy_note_for_rewrite(cfg, current_head-object.sha1, 
sha1);
finish_copy_notes_for_rewrite(cfg, Notes added by 'git 
commit --amend');
}
-   run_rewrite_hook(current_head-object.sha1, sha1);
+   add_rewritten(rewrite, current_head-object.sha1, sha1);
+   run_rewrite_hook(rewrite, amend);
}
if (!quiet)
print_summary(prefix, sha1, !current_head);
diff --git a/rewrite.c b/rewrite.c
index 2793688..c8efaa8 100644
--- a/rewrite.c
+++ b/rewrite.c
@@ -1,5 +1,6 @@
 #include cache.h
 #include rewrite.h
+#include run-command.h
 
 void add_rewritten(struct rewritten *list, unsigned char *from, unsigned char 
*to)
 {
@@ -69,3 +70,34 @@ void load_rewritten(struct rewritten *list, const char *file)
}
strbuf_release(buf);
 }
+
+int run_rewrite_hook(struct rewritten *list, const char *name)
+{
+   struct strbuf buf = STRBUF_INIT;
+   struct child_process proc;
+   const char *argv[3];
+   int code, i;
+
+   argv[0] = find_hook(post-rewrite);
+   if (!argv[0])
+   return 0;
+
+   argv[1] = name;
+   argv[2] = NULL;
+
+   memset(proc, 0, sizeof(proc));
+   proc.argv = argv;
+   proc.in = -1;
+   proc.stdout_to_stderr = 1;
+
+   code = start_command(proc);
+   if (code)
+   return code;
+   for (i = 0; i  list-nr; i++) {
+   struct rewritten_item *item = list-items[i];
+   strbuf_addf(buf, %s %s\n, sha1_to_hex(item-from), 
sha1_to_hex(item-to));
+   }
+   write_in_full(proc.in, buf.buf, buf.len);
+   close(proc.in);
+   return finish_command(proc);
+}
diff --git a/rewrite.h b/rewrite.h
index 09e7222..fd00e66 100644
--- a/rewrite.h
+++ b/rewrite.h
@@ -14,5 +14,6 @@ struct rewritten {
 void add_rewritten(struct rewritten *list, unsigned char *from, unsigned char 
*to);
 int store_rewritten(struct rewritten *list, const char *file);
 void load_rewritten(struct rewritten *list, const char *file);
+int run_rewrite_hook(struct rewritten *list, const char *name);
 
 #endif
-- 
1.8.4-fc

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


[PATCH v6 26/28] rebase: cherry-pick: add merge options

2013-08-30 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 git-rebase--cherrypick.sh | 9 +
 1 file changed, 9 insertions(+)

diff --git a/git-rebase--cherrypick.sh b/git-rebase--cherrypick.sh
index d36b0dc..bda7cfc 100644
--- a/git-rebase--cherrypick.sh
+++ b/git-rebase--cherrypick.sh
@@ -45,6 +45,15 @@ else
 fi
 test -n $GIT_QUIET  extra=$extra -q
 test -z $force_rebase  extra=$extra --ff
+test -n $strategy  extra=$extra --strategy=$strategy
+for x in $strategy_opts
+do
+   test -z $x  continue
+   x=$(eval echo $x)
+   extra=$extra -X${x#--}
+done
+test -n $allow_rerere_autoupdate  extra=$extra $allow_rerere_autoupdate
+
 git cherry-pick --no-merges --right-only --topo-order --do-walk --action-name 
rebase $extra $revisions
 ret=$?
 
-- 
1.8.4-fc

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


[PATCH v6 15/28] rebase: cherry-pick: fix sequence continuation

2013-08-30 Thread Felipe Contreras
We are not in am mode.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 git-rebase--cherrypick.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/git-rebase--cherrypick.sh b/git-rebase--cherrypick.sh
index e142cfb..d8d32fe 100644
--- a/git-rebase--cherrypick.sh
+++ b/git-rebase--cherrypick.sh
@@ -5,12 +5,12 @@
 
 case $action in
 continue)
-   git am --resolved --resolvemsg=$resolvemsg 
+   git cherry-pick --continue 
move_to_original_branch
return
;;
 skip)
-   git am --skip --resolvemsg=$resolvemsg 
+   git cherry-pick --skip 
move_to_original_branch
return
;;
-- 
1.8.4-fc

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


[PATCH v6 18/28] rebase: cherry-pick: fix status messages

2013-08-30 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 git-rebase--cherrypick.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/git-rebase--cherrypick.sh b/git-rebase--cherrypick.sh
index e9e..be17ec4 100644
--- a/git-rebase--cherrypick.sh
+++ b/git-rebase--cherrypick.sh
@@ -3,6 +3,9 @@
 # Copyright (c) 2010 Junio C Hamano.
 #
 
+GIT_CHERRY_PICK_HELP=$resolvemsg
+export GIT_CHERRY_PICK_HELP
+
 case $action in
 continue)
git cherry-pick --continue 
-- 
1.8.4-fc

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


[PATCH v6 28/28] rebase: cherry-pick: add copyright

2013-08-30 Thread Felipe Contreras
Probably enough changes to warrant that.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 git-rebase--cherrypick.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/git-rebase--cherrypick.sh b/git-rebase--cherrypick.sh
index bda7cfc..da949aa 100644
--- a/git-rebase--cherrypick.sh
+++ b/git-rebase--cherrypick.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# Copyright (c) 2010 Junio C Hamano.
+# Copyright (c) 2013 Felipe Contreras
 #
 
 GIT_CHERRY_PICK_HELP=$resolvemsg
-- 
1.8.4-fc

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


[PATCH v6 16/28] rebase: cherry-pick: fix abort of cherry mode

2013-08-30 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 git-rebase.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/git-rebase.sh b/git-rebase.sh
index b28addc..db2ea8d 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -368,6 +368,7 @@ skip)
run_specific_rebase
;;
 abort)
+   test $type == cherrypick  git cherry-pick --abort
git rerere clear
read_basic_state
case $head_name in
-- 
1.8.4-fc

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


[PATCH v6 10/28] cherry-pick: add --action-name option

2013-08-30 Thread Felipe Contreras
So it can be used by other tools (e.g. git rebase), and the right action
is passed to the hooks and notes rewrite stuff.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 builtin/revert.c   | 2 ++
 git-rebase--interactive.sh | 4 ++--
 sequencer.c| 6 +-
 sequencer.h| 2 ++
 4 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/builtin/revert.c b/builtin/revert.c
index d3ae2c4..ca28e52 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -124,6 +124,7 @@ static void parse_args(int argc, const char **argv, struct 
replay_opts *opts)
OPT_END(),
OPT_END(),
OPT_END(),
+   OPT_END(),
};
 
if (opts-action == REPLAY_PICK) {
@@ -134,6 +135,7 @@ static void parse_args(int argc, const char **argv, struct 
replay_opts *opts)
OPT_BOOLEAN(0, allow-empty-message, 
opts-allow_empty_message, N_(allow commits with empty messages)),
OPT_BOOLEAN(0, keep-redundant-commits, 
opts-keep_redundant_commits, N_(keep redundant, empty commits)),
OPT_BOOLEAN(0, skip-empty, opts-skip_empty, 
N_(skip empty commits)),
+   OPT_STRING(0, action-name, opts-action_name, 
N_(name), N_(action name)),
OPT_END(),
};
if (parse_options_concat(options, ARRAY_SIZE(options), 
cp_extra))
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 83d6d46..e8143ae 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -251,7 +251,7 @@ pick_one () {
 
test -d $rewritten 
pick_one_preserving_merges $@  return
-   output eval git cherry-pick $strategy_args $empty_args $ff $@
+   output eval git cherry-pick --action-name '' $strategy_args 
$empty_args $ff $@
 }
 
 pick_one_preserving_merges () {
@@ -361,7 +361,7 @@ pick_one_preserving_merges () {
echo $sha1 $(git rev-parse HEAD^0)  
$rewritten_list
;;
*)
-   output eval git cherry-pick $strategy_args $@ ||
+   output eval git cherry-pick --action-name '' 
$strategy_args $@ ||
die_with_patch $sha1 Could not pick $sha1
;;
esac
diff --git a/sequencer.c b/sequencer.c
index 56d791f..46848c4 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -829,7 +829,9 @@ static int populate_opts_cb(const char *key, const char 
*value, void *data)
else if (!strcmp(key, options.strategy-option)) {
ALLOC_GROW(opts-xopts, opts-xopts_nr + 1, opts-xopts_alloc);
opts-xopts[opts-xopts_nr++] = xstrdup(value);
-   } else
+   } else if (!strcmp(key, options.action-name))
+   git_config_string(opts-action_name, key, value);
+   else
return error(_(Invalid key: %s), key);
 
if (!error_flag)
@@ -1006,6 +1008,8 @@ static void save_opts(struct replay_opts *opts)

options.strategy-option,
opts-xopts[i], ^$, 
0);
}
+   if (opts-action_name)
+   git_config_set_in_file(opts_file, options.action-name, 
opts-action_name);
 }
 
 static int pick_commits(struct commit_list *todo_list, struct replay_opts 
*opts)
diff --git a/sequencer.h b/sequencer.h
index efec1b5..6dfffaa 100644
--- a/sequencer.h
+++ b/sequencer.h
@@ -48,6 +48,8 @@ struct replay_opts {
 
/* Only used by REPLAY_NONE */
struct rev_info *revs;
+
+   const char *action_name;
 };
 
 int sequencer_pick_revisions(struct replay_opts *opts);
-- 
1.8.4-fc

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


[PATCH v6 14/28] rebase: cherry-pick: fix mode storage

2013-08-30 Thread Felipe Contreras
We don't use the 'rebase-apply'.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 git-rebase--cherrypick.sh | 5 -
 git-rebase.sh | 5 -
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/git-rebase--cherrypick.sh b/git-rebase--cherrypick.sh
index 2c16995..e142cfb 100644
--- a/git-rebase--cherrypick.sh
+++ b/git-rebase--cherrypick.sh
@@ -18,12 +18,15 @@ esac
 
 test -n $rebase_root  root_flag=--root
 
+mkdir -p $state_dir || die Could not create temporary $state_dir
+:  $state_dir/cherrypick || die Could not mark as cherrypick
+
 git cherry-pick --allow-empty $revisions
 ret=$?
 
 if test 0 != $ret
 then
-   test -d $state_dir  write_basic_state
+   write_basic_state
return $ret
 fi
 
diff --git a/git-rebase.sh b/git-rebase.sh
index 2310638..b28addc 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -204,6 +204,9 @@ then
then
type=interactive
interactive_rebase=explicit
+   elif test -f $merge_dir/cherrypick
+   then
+   type=cherrypick
else
type=merge
fi
@@ -415,7 +418,7 @@ then
 elif test -n $keep_empty
 then
type=cherrypick
-   state_dir=$apply_dir
+   state_dir=$merge_dir
 else
type=am
state_dir=$apply_dir
-- 
1.8.4-fc

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


[PATCH v6 19/28] rebase: cherry-pick: automatically commit stage

2013-08-30 Thread Felipe Contreras
When there's changes in the staging area. Just like the other rebase
modes.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 git-rebase--cherrypick.sh | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/git-rebase--cherrypick.sh b/git-rebase--cherrypick.sh
index be17ec4..241cda7 100644
--- a/git-rebase--cherrypick.sh
+++ b/git-rebase--cherrypick.sh
@@ -8,6 +8,12 @@ export GIT_CHERRY_PICK_HELP
 
 case $action in
 continue)
+   # do we have anything to commit?
+   if ! git diff-index --cached --quiet HEAD --
+   then
+   git commit --no-verify -e ||
+   die Could not commit staged changes.
+   fi
git cherry-pick --continue 
move_to_original_branch
return
-- 
1.8.4-fc

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


[PATCH v6 12/28] cherry-pick: remember rerere-autoupdate

2013-08-30 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 sequencer.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/sequencer.c b/sequencer.c
index 076bb9d..453e4a4 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -847,6 +847,8 @@ static int populate_opts_cb(const char *key, const char 
*value, void *data)
opts-xopts[opts-xopts_nr++] = xstrdup(value);
} else if (!strcmp(key, options.action-name))
git_config_string(opts-action_name, key, value);
+   else if (!strcmp(key, options.allow-rerere-auto))
+   opts-allow_rerere_auto = git_config_int(key, value);
else
return error(_(Invalid key: %s), key);
 
@@ -1026,6 +1028,12 @@ static void save_opts(struct replay_opts *opts)
}
if (opts-action_name)
git_config_set_in_file(opts_file, options.action-name, 
opts-action_name);
+   if (opts-allow_rerere_auto) {
+   struct strbuf buf = STRBUF_INIT;
+   strbuf_addf(buf, %d, opts-allow_rerere_auto);
+   git_config_set_in_file(opts_file, options.allow-rerere-auto, 
buf.buf);
+   strbuf_release(buf);
+   }
 }
 
 static int pick_commits(struct commit_list *todo_list, struct replay_opts 
*opts)
-- 
1.8.4-fc

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


[PATCH v6 07/28] cherry-pick: don't store skipped commit

2013-08-30 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 sequencer.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sequencer.c b/sequencer.c
index 468fa54..56d791f 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1047,7 +1047,7 @@ static int continue_single_pick(void)
return run_command_v_opt(argv, RUN_GIT_CMD);
 }
 
-static int sequencer_continue(struct replay_opts *opts)
+static int sequencer_continue(struct replay_opts *opts, int skip)
 {
struct commit_list *todo_list = NULL;
 
@@ -1067,7 +1067,7 @@ static int sequencer_continue(struct replay_opts *opts)
}
if (index_differs_from(HEAD, 0))
return error_dirty_index(opts);
-   if (opts-action == REPLAY_PICK) {
+   if (opts-action == REPLAY_PICK  !skip) {
unsigned char to[20];
if (!read_ref(HEAD, to))
add_rewritten(rewritten, todo_list-item-object.sha1, 
to);
@@ -1095,7 +1095,7 @@ static int sequencer_skip(struct replay_opts *opts)
if (ret)
return ret;
 
-   return sequencer_continue(opts);
+   return sequencer_continue(opts, 1);
 }
 
 static int single_pick(struct commit *cmit, struct replay_opts *opts)
@@ -1127,7 +1127,7 @@ int sequencer_pick_revisions(struct replay_opts *opts)
if (opts-subcommand == REPLAY_ROLLBACK)
return sequencer_rollback(opts);
if (opts-subcommand == REPLAY_CONTINUE)
-   return sequencer_continue(opts);
+   return sequencer_continue(opts, 0);
if (opts-subcommand == REPLAY_SKIP)
return sequencer_skip(opts);
 
-- 
1.8.4-fc

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


[PATCH v6 25/28] rebase: use 'cherrypick' mode instead of 'am'

2013-08-30 Thread Felipe Contreras
Unless any specific 'git am' options are used.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 git-rebase.sh  | 8 
 t/t3407-rebase-abort.sh| 2 +-
 t/t3420-rebase-autostash.sh| 2 +-
 t/t3425-rebase-topology-merges.sh  | 6 +++---
 t/t5520-pull.sh| 2 +-
 t/t9106-git-svn-commit-diff-clobber.sh | 2 +-
 6 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/git-rebase.sh b/git-rebase.sh
index ebe87a3..f0291df 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -415,13 +415,13 @@ elif test -n $do_merge
 then
type=merge
state_dir=$merge_dir
-elif test -n $keep_empty
+elif test -n $git_am_opt
 then
-   type=cherrypick
-   state_dir=$merge_dir
-else
type=am
state_dir=$apply_dir
+else
+   type=cherrypick
+   state_dir=$merge_dir
 fi
 
 if test -z $rebase_root
diff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh
index a6a6c40..2699b08 100755
--- a/t/t3407-rebase-abort.sh
+++ b/t/t3407-rebase-abort.sh
@@ -96,7 +96,7 @@ testrebase() {
'
 }
 
-testrebase  .git/rebase-apply
+testrebase  .git/rebase-merge
 testrebase  --merge .git/rebase-merge
 
 test_done
diff --git a/t/t3420-rebase-autostash.sh b/t/t3420-rebase-autostash.sh
index c179262..58bf705 100755
--- a/t/t3420-rebase-autostash.sh
+++ b/t/t3420-rebase-autostash.sh
@@ -162,7 +162,7 @@ test_expect_success rebase: noop rebase '
)
 '
 
-testrebase  .git/rebase-apply
+testrebase  .git/rebase-merge
 testrebase  --merge .git/rebase-merge
 testrebase  --interactive .git/rebase-merge
 
diff --git a/t/t3425-rebase-topology-merges.sh 
b/t/t3425-rebase-topology-merges.sh
index 1d195fb..99b4535 100755
--- a/t/t3425-rebase-topology-merges.sh
+++ b/t/t3425-rebase-topology-merges.sh
@@ -71,7 +71,7 @@ test_run_rebase () {

 }
 #TODO: make order consistent across all flavors of rebase
-test_run_rebase success 'e n o' ''
+test_run_rebase success 'n o e' ''
 test_run_rebase success 'e n o' -m
 test_run_rebase success 'n o e' -i
 
@@ -88,7 +88,7 @@ test_run_rebase () {

 }
 #TODO: make order consistent across all flavors of rebase
-test_run_rebase success 'd e n o' ''
+test_run_rebase success 'd n o e' ''
 test_run_rebase success 'd e n o' -m
 test_run_rebase success 'd n o e' -i
 
@@ -105,7 +105,7 @@ test_run_rebase () {

 }
 #TODO: make order consistent across all flavors of rebase
-test_run_rebase success 'd e n o' ''
+test_run_rebase success 'd n o e' ''
 test_run_rebase success 'd e n o' -m
 test_run_rebase success 'd n o e' -i
 
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index ed4d9c8..751b50d 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -273,7 +273,7 @@ test_expect_success 'setup for avoiding reapplying old 
patches' '
 test_expect_success 'git pull --rebase does not reapply old patches' '
(cd dst 
 test_must_fail git pull --rebase 
-test 1 = $(find .git/rebase-apply -name 000* | wc -l)
+test 1 = $(cat .git/sequencer/todo | wc -l)
)
 '
 
diff --git a/t/t9106-git-svn-commit-diff-clobber.sh 
b/t/t9106-git-svn-commit-diff-clobber.sh
index f6d7ac7..b9cec33 100755
--- a/t/t9106-git-svn-commit-diff-clobber.sh
+++ b/t/t9106-git-svn-commit-diff-clobber.sh
@@ -92,7 +92,7 @@ test_expect_success 'multiple dcommit from git svn will not 
clobber svn' 
 
 
 test_expect_success 'check that rebase really failed' '
-   test -d .git/rebase-apply
+   test -d .git/rebase-merge
 '
 
 test_expect_success 'resolve, continue the rebase and dcommit' 
-- 
1.8.4-fc

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


[PATCH v6 20/28] rebase: cherry-pick: set correct action-name

2013-08-30 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 git-rebase--cherrypick.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/git-rebase--cherrypick.sh b/git-rebase--cherrypick.sh
index 241cda7..d36b0dc 100644
--- a/git-rebase--cherrypick.sh
+++ b/git-rebase--cherrypick.sh
@@ -45,7 +45,7 @@ else
 fi
 test -n $GIT_QUIET  extra=$extra -q
 test -z $force_rebase  extra=$extra --ff
-git cherry-pick --no-merges --right-only --topo-order --do-walk $extra 
$revisions
+git cherry-pick --no-merges --right-only --topo-order --do-walk --action-name 
rebase $extra $revisions
 ret=$?
 
 if test 0 != $ret
-- 
1.8.4-fc

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


[PATCH v6 24/28] prompt: parse cherry-pick rebase mode

2013-08-30 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 contrib/completion/git-prompt.sh | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index a81ef5a..a7bde16 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -313,12 +313,18 @@ __git_ps1 ()
local total=
if [ -d $g/rebase-merge ]; then
read b 2/dev/null $g/rebase-merge/head-name
-   read step 2/dev/null $g/rebase-merge/msgnum
-   read total 2/dev/null $g/rebase-merge/end
-   if [ -f $g/rebase-merge/interactive ]; then
-   r=|REBASE-i
+   if [ -f $g/rebase-merge/cherrypick ]; then
+   read total 2/dev/null $g/sequencer/total
+   read step 2/dev/null $g/sequencer/step
+   r=|REBASE
else
-   r=|REBASE-m
+   read step 2/dev/null $g/rebase-merge/msgnum
+   read total 2/dev/null $g/rebase-merge/end
+   if [ -f $g/rebase-merge/interactive ]; then
+   r=|REBASE-i
+   else
+   r=|REBASE-m
+   fi
fi
else
if [ -d $g/rebase-apply ]; then
-- 
1.8.4-fc

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


[PATCH v6 23/28] sequencer: store progress information

2013-08-30 Thread Felipe Contreras
So that it can be used by shell prompts.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 sequencer.c | 24 ++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/sequencer.c b/sequencer.c
index 453e4a4..c855dd4 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -21,6 +21,7 @@
 const char sign_off_header[] = Signed-off-by: ;
 static const char cherry_picked_prefix[] = (cherry picked from commit ;
 static struct rewritten rewritten;
+static int total;
 
 static void finish(struct replay_opts *opts)
 {
@@ -877,8 +878,10 @@ static void walk_revs_populate_todo(struct commit_list 
**todo_list,
prepare_revs(opts);
 
next = todo_list;
-   while ((commit = get_revision(opts-revs)))
+   while ((commit = get_revision(opts-revs))) {
next = commit_list_append(commit, next);
+   total++;
+   }
 }
 
 static int create_seq_dir(void)
@@ -1036,6 +1039,21 @@ static void save_opts(struct replay_opts *opts)
}
 }
 
+static void save_info(int total, int step)
+{
+   FILE *f;
+   f = fopen(git_path(sequencer/total), w);
+   if (f) {
+   fprintf(f, %i\n, total);
+   fclose(f);
+   }
+   f = fopen(git_path(sequencer/step), w);
+   if (f) {
+   fprintf(f, %i\n, step);
+   fclose(f);
+   }
+}
+
 static int pick_commits(struct commit_list *todo_list, struct replay_opts 
*opts)
 {
struct commit_list *cur;
@@ -1051,8 +1069,10 @@ static int pick_commits(struct commit_list *todo_list, 
struct replay_opts *opts)
save_todo(cur, opts);
res = do_pick_commit(cur-item, opts);
if (res) {
-   if (opts-action == REPLAY_PICK)
+   if (opts-action == REPLAY_PICK) {
store_rewritten(rewritten, 
git_path(SEQ_REWR_FILE));
+   save_info(total, rewritten.nr + 1);
+   }
return res;
}
}
-- 
1.8.4-fc

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


[PATCH v6 21/28] rebase: trivial cleanup

2013-08-30 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 git-rebase--am.sh | 1 +
 git-rebase.sh | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/git-rebase--am.sh b/git-rebase--am.sh
index aae6a85..d6a434c 100644
--- a/git-rebase--am.sh
+++ b/git-rebase--am.sh
@@ -51,6 +51,7 @@ ret=0
return $?
fi
 
+   test -n $GIT_QUIET  git_am_opt=$git_am_opt -q
git am $git_am_opt --rebasing --resolvemsg=$resolvemsg 
$GIT_DIR/rebased-patches
ret=$?
 
diff --git a/git-rebase.sh b/git-rebase.sh
index db2ea8d..ebe87a3 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -284,7 +284,6 @@ do
;;
-q)
GIT_QUIET=t
-   git_am_opt=$git_am_opt -q
verbose=
diffstat=
;;
-- 
1.8.4-fc

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


[PATCH v6 11/28] cherry-pick: copy notes and run hooks

2013-08-30 Thread Felipe Contreras
If no action-name is specified, nothing is done.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 Documentation/config.txt   |  9 -
 Documentation/githooks.txt |  8 
 rewrite.c  |  1 +
 sequencer.c| 25 -
 4 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index ec57a15..7e7f89f 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1691,11 +1691,10 @@ GIT_NOTES_REF) is also implicitly added to the list of 
refs to be
 displayed.
 
 notes.rewrite.command::
-   When rewriting commits with command (currently `amend` or
-   `rebase`) and this variable is set to `true`, Git
-   automatically copies your notes from the original to the
-   rewritten commit.  Defaults to `true`, but see
-   notes.rewriteRef below.
+   When rewriting commits with command (currently `amend`, `rebase`, or
+   `cherry-pick`) and this variable is set to `true`, Git automatically
+   copies your notes from the original to the rewritten commit.  Defaults
+   to `true`, but see notes.rewriteRef below.
 
 notes.rewriteMode::
When copying notes during a rewrite (see the
diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt
index d48bf4d..8cfa13b 100644
--- a/Documentation/githooks.txt
+++ b/Documentation/githooks.txt
@@ -352,10 +352,10 @@ post-rewrite
 
 
 This hook is invoked by commands that rewrite commits (`git commit
---amend`, 'git-rebase'; currently 'git-filter-branch' does 'not' call
-it!).  Its first argument denotes the command it was invoked by:
-currently one of `amend` or `rebase`.  Further command-dependent
-arguments may be passed in the future.
+--amend`, `git rebase`, `git cherry-pick`; currently `git filter-branch` does
+'not' call it!).  Its first argument denotes the command it was invoked by
+(e.g. `rebase`).  Further command-dependent arguments may be passed in the
+future.
 
 The hook receives a list of the rewritten commits on stdin, in the
 format
diff --git a/rewrite.c b/rewrite.c
index 4dddcd9..4f95094 100644
--- a/rewrite.c
+++ b/rewrite.c
@@ -2,6 +2,7 @@
 #include rewrite.h
 #include run-command.h
 #include notes-utils.h
+#include builtin.h
 
 void add_rewritten(struct rewritten *list, unsigned char *from, unsigned char 
*to)
 {
diff --git a/sequencer.c b/sequencer.c
index 46848c4..076bb9d 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -22,6 +22,22 @@ const char sign_off_header[] = Signed-off-by: ;
 static const char cherry_picked_prefix[] = (cherry picked from commit ;
 static struct rewritten rewritten;
 
+static void finish(struct replay_opts *opts)
+{
+   const char *name;
+
+   if (opts-action != REPLAY_PICK)
+   return;
+
+   name = opts-action_name ? opts-action_name : cherry-pick;
+
+   if (!*name)
+   return;
+
+   copy_rewrite_notes(rewritten, name, Notes added by 'git 
cherry-pick');
+   run_rewrite_hook(rewritten, name);
+}
+
 static int is_rfc2822_line(const char *buf, int len)
 {
int i;
@@ -1033,6 +1049,8 @@ static int pick_commits(struct commit_list *todo_list, 
struct replay_opts *opts)
}
}
 
+   finish(opts);
+
/*
 * Sequence of picks finished successfully; cleanup by
 * removing the .git/sequencer directory
@@ -1104,8 +1122,13 @@ static int sequencer_skip(struct replay_opts *opts)
 
 static int single_pick(struct commit *cmit, struct replay_opts *opts)
 {
+   int ret;
setenv(GIT_REFLOG_ACTION, action_name(opts), 0);
-   return do_pick_commit(cmit, opts);
+   ret = do_pick_commit(cmit, opts);
+   if (ret)
+   return ret;
+   finish(opts);
+   return 0;
 }
 
 int sequencer_pick_revisions(struct replay_opts *opts)
-- 
1.8.4-fc

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


[PATCH v6 27/28] rebase: remove merge mode

2013-08-30 Thread Felipe Contreras
The cherrypick mode does the job.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 .gitignore|   1 -
 Makefile  |   1 -
 git-rebase--interactive.sh|   2 +-
 git-rebase--merge.sh  | 151 --
 git-rebase.sh |  13 +---
 t/t3406-rebase-message.sh |  14 +---
 t/t3425-rebase-topology-merges.sh |   9 +--
 t/t9903-bash-prompt.sh|   2 +-
 8 files changed, 7 insertions(+), 186 deletions(-)
 delete mode 100644 git-rebase--merge.sh

diff --git a/.gitignore b/.gitignore
index 3514737..7b64376 100644
--- a/.gitignore
+++ b/.gitignore
@@ -116,7 +116,6 @@
 /git-rebase--am
 /git-rebase--cherrypick
 /git-rebase--interactive
-/git-rebase--merge
 /git-receive-pack
 /git-reflog
 /git-relink
diff --git a/Makefile b/Makefile
index 2d6521e..f73e060 100644
--- a/Makefile
+++ b/Makefile
@@ -475,7 +475,6 @@ SCRIPT_LIB += git-parse-remote
 SCRIPT_LIB += git-rebase--am
 SCRIPT_LIB += git-rebase--cherrypick
 SCRIPT_LIB += git-rebase--interactive
-SCRIPT_LIB += git-rebase--merge
 SCRIPT_LIB += git-sh-setup
 SCRIPT_LIB += git-sh-i18n
 
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index e8143ae..58aad45 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -81,7 +81,7 @@ rewritten_list=$state_dir/rewritten-list
 rewritten_pending=$state_dir/rewritten-pending
 
 strategy_args=
-if test -n $do_merge
+if test -n $strategy
 then
strategy_args=${strategy:+--strategy=$strategy}
eval '
diff --git a/git-rebase--merge.sh b/git-rebase--merge.sh
deleted file mode 100644
index 16d1817..000
--- a/git-rebase--merge.sh
+++ /dev/null
@@ -1,151 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2010 Junio C Hamano.
-#
-
-prec=4
-
-read_state () {
-   onto_name=$(cat $state_dir/onto_name) 
-   end=$(cat $state_dir/end) 
-   msgnum=$(cat $state_dir/msgnum)
-}
-
-continue_merge () {
-   test -d $state_dir || die $state_dir directory does not exist
-
-   unmerged=$(git ls-files -u)
-   if test -n $unmerged
-   then
-   echo You still have unmerged paths in your index
-   echo did you forget to use git add?
-   die $resolvemsg
-   fi
-
-   cmt=`cat $state_dir/current`
-   if ! git diff-index --quiet --ignore-submodules HEAD --
-   then
-   if ! git commit --no-verify -C $cmt
-   then
-   echo Commit failed, please do not call \git commit\
-   echo directly, but instead do one of the following: 
-   die $resolvemsg
-   fi
-   if test -z $GIT_QUIET
-   then
-   printf Committed: %0${prec}d  $msgnum
-   fi
-   echo $cmt $(git rev-parse HEAD^0)  $state_dir/rewritten
-   else
-   if test -z $GIT_QUIET
-   then
-   printf Already applied: %0${prec}d  $msgnum
-   fi
-   fi
-   test -z $GIT_QUIET 
-   GIT_PAGER='' git log --format=%s -1 $cmt
-
-   # onto the next patch:
-   msgnum=$(($msgnum + 1))
-   echo $msgnum $state_dir/msgnum
-}
-
-call_merge () {
-   cmt=$(cat $state_dir/cmt.$1)
-   echo $cmt  $state_dir/current
-   hd=$(git rev-parse --verify HEAD)
-   cmt_name=$(git symbolic-ref HEAD 2 /dev/null || echo HEAD)
-   msgnum=$(cat $state_dir/msgnum)
-   eval GITHEAD_$cmt='${cmt_name##refs/heads/}~$(($end - $msgnum))'
-   eval GITHEAD_$hd='$onto_name'
-   export GITHEAD_$cmt GITHEAD_$hd
-   if test -n $GIT_QUIET
-   then
-   GIT_MERGE_VERBOSITY=1  export GIT_MERGE_VERBOSITY
-   fi
-   test -z $strategy  strategy=recursive
-   eval 'git-merge-$strategy' $strategy_opts '$cmt^ -- $hd $cmt'
-   rv=$?
-   case $rv in
-   0)
-   unset GITHEAD_$cmt GITHEAD_$hd
-   return
-   ;;
-   1)
-   git rerere $allow_rerere_autoupdate
-   die $resolvemsg
-   ;;
-   2)
-   echo Strategy: $strategy failed, try another 12
-   die $resolvemsg
-   ;;
-   *)
-   die Unknown exit code ($rv) from command: \
-   git-merge-$strategy $cmt^ -- HEAD $cmt
-   ;;
-   esac
-}
-
-finish_rb_merge () {
-   move_to_original_branch
-   if test -s $state_dir/rewritten
-   then
-   git notes copy --for-rewrite=rebase $state_dir/rewritten
-   if test -x $GIT_DIR/hooks/post-rewrite
-   then
-   $GIT_DIR/hooks/post-rewrite rebase 
$state_dir/rewritten
-   fi
-   fi
-   say All done.
-}
-
-case $action in
-continue)
-   read_state
-   continue_merge
-   while test $msgnum -le $end
-   do
-   call_merge $msgnum
-   

[PATCH v6 13/28] rebase: split the cherry-pick stuff

2013-08-30 Thread Felipe Contreras
They do something completely different from 'git am', it belongs in a
different file.

No functional changes.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 .gitignore|  1 +
 Makefile  |  1 +
 git-rebase--am.sh | 11 +--
 git-rebase--cherrypick.sh | 30 ++
 git-rebase.sh |  4 
 5 files changed, 37 insertions(+), 10 deletions(-)
 create mode 100644 git-rebase--cherrypick.sh

diff --git a/.gitignore b/.gitignore
index 6b1fd1b..3514737 100644
--- a/.gitignore
+++ b/.gitignore
@@ -114,6 +114,7 @@
 /git-read-tree
 /git-rebase
 /git-rebase--am
+/git-rebase--cherrypick
 /git-rebase--interactive
 /git-rebase--merge
 /git-receive-pack
diff --git a/Makefile b/Makefile
index 9396d57..2d6521e 100644
--- a/Makefile
+++ b/Makefile
@@ -473,6 +473,7 @@ SCRIPT_SH += git-web--browse.sh
 SCRIPT_LIB += git-mergetool--lib
 SCRIPT_LIB += git-parse-remote
 SCRIPT_LIB += git-rebase--am
+SCRIPT_LIB += git-rebase--cherrypick
 SCRIPT_LIB += git-rebase--interactive
 SCRIPT_LIB += git-rebase--merge
 SCRIPT_LIB += git-sh-setup
diff --git a/git-rebase--am.sh b/git-rebase--am.sh
index 34e3102..aae6a85 100644
--- a/git-rebase--am.sh
+++ b/git-rebase--am.sh
@@ -19,15 +19,7 @@ esac
 test -n $rebase_root  root_flag=--root
 
 ret=0
-if test -n $keep_empty
-then
-   # we have to do this the hard way.  git format-patch completely squashes
-   # empty commits and even if it didn't the format doesn't really lend
-   # itself well to recording empty patches.  fortunately, cherry-pick
-   # makes this easy
-   git cherry-pick --allow-empty $revisions
-   ret=$?
-else
+
rm -f $GIT_DIR/rebased-patches
 
git format-patch -k --stdout --full-index --ignore-if-in-upstream \
@@ -63,7 +55,6 @@ else
ret=$?
 
rm -f $GIT_DIR/rebased-patches
-fi
 
 if test 0 != $ret
 then
diff --git a/git-rebase--cherrypick.sh b/git-rebase--cherrypick.sh
new file mode 100644
index 000..2c16995
--- /dev/null
+++ b/git-rebase--cherrypick.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Junio C Hamano.
+#
+
+case $action in
+continue)
+   git am --resolved --resolvemsg=$resolvemsg 
+   move_to_original_branch
+   return
+   ;;
+skip)
+   git am --skip --resolvemsg=$resolvemsg 
+   move_to_original_branch
+   return
+   ;;
+esac
+
+test -n $rebase_root  root_flag=--root
+
+git cherry-pick --allow-empty $revisions
+ret=$?
+
+if test 0 != $ret
+then
+   test -d $state_dir  write_basic_state
+   return $ret
+fi
+
+move_to_original_branch
diff --git a/git-rebase.sh b/git-rebase.sh
index 8d7659a..2310638 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -412,6 +412,10 @@ elif test -n $do_merge
 then
type=merge
state_dir=$merge_dir
+elif test -n $keep_empty
+then
+   type=cherrypick
+   state_dir=$apply_dir
 else
type=am
state_dir=$apply_dir
-- 
1.8.4-fc

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


[PATCH v6 22/28] t: rebase-autostash: fix setup

2013-08-30 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 t/t3420-rebase-autostash.sh | 105 ++--
 1 file changed, 52 insertions(+), 53 deletions(-)

diff --git a/t/t3420-rebase-autostash.sh b/t/t3420-rebase-autostash.sh
index 90eb264..c179262 100755
--- a/t/t3420-rebase-autostash.sh
+++ b/t/t3420-rebase-autostash.sh
@@ -33,54 +33,56 @@ test_expect_success setup '
git commit -m related commit
 '
 
+setup_tmp () {
+   git clone . tmp 
+   cd tmp 
+   git fetch -u origin refs/heads/*:refs/heads/* 
+   test_config rebase.autostash true 
+   git checkout -b rebased-feature-branch feature-branch
+}
+
 testrebase() {
type=$1
dotest=$2
 
test_expect_success rebase$type: dirty worktree, non-conflicting 
rebase '
-   test_config rebase.autostash true 
-   git reset --hard 
-   git checkout -b rebased-feature-branch feature-branch 
-   test_when_finished git branch -D rebased-feature-branch 
+   test_when_finished rm -rf tmp 
+   (
+   setup_tmp 
echo dirty file3 
git rebase$type unrelated-onto-branch 
grep unrelated file4 
-   grep dirty file3 
-   git checkout feature-branch
+   grep dirty file3
+   )
'
 
test_expect_success rebase$type: dirty index, non-conflicting rebase '
-   test_config rebase.autostash true 
-   git reset --hard 
-   git checkout -b rebased-feature-branch feature-branch 
-   test_when_finished git branch -D rebased-feature-branch 
+   test_when_finished rm -rf tmp 
+   (
+   setup_tmp 
echo dirty file3 
git add file3 
git rebase$type unrelated-onto-branch 
grep unrelated file4 
-   grep dirty file3 
-   git checkout feature-branch
+   grep dirty file3
+   )
'
 
test_expect_success rebase$type: conflicting rebase '
-   test_config rebase.autostash true 
-   git reset --hard 
-   git checkout -b rebased-feature-branch feature-branch 
-   test_when_finished git branch -D rebased-feature-branch 
+   test_when_finished rm -rf tmp 
+   (
+   setup_tmp 
echo dirty file3 
test_must_fail git rebase$type related-onto-branch 
test_path_is_file $dotest/autostash 
-   ! grep dirty file3 
-   rm -rf $dotest 
-   git reset --hard 
-   git checkout feature-branch
+   ! grep dirty file3
+   )
'
 
test_expect_success rebase$type: --continue '
-   test_config rebase.autostash true 
-   git reset --hard 
-   git checkout -b rebased-feature-branch feature-branch 
-   test_when_finished git branch -D rebased-feature-branch 
+   test_when_finished rm -rf tmp 
+   (
+   setup_tmp 
echo dirty file3 
test_must_fail git rebase$type related-onto-branch 
test_path_is_file $dotest/autostash 
@@ -89,45 +91,43 @@ testrebase() {
git add file2 
git rebase --continue 
test_path_is_missing $dotest/autostash 
-   grep dirty file3 
-   git checkout feature-branch
+   grep dirty file3
+   )
'
 
test_expect_success rebase$type: --skip '
-   test_config rebase.autostash true 
+   test_when_finished rm -rf tmp 
+   (
+   setup_tmp 
git reset --hard 
-   git checkout -b rebased-feature-branch feature-branch 
-   test_when_finished git branch -D rebased-feature-branch 
echo dirty file3 
test_must_fail git rebase$type related-onto-branch 
test_path_is_file $dotest/autostash 
! grep dirty file3 
git rebase --skip 
test_path_is_missing $dotest/autostash 
-   grep dirty file3 
-   git checkout feature-branch
+   grep dirty file3
+   )
'
 
test_expect_success rebase$type: --abort '
-   test_config rebase.autostash true 
-   git reset --hard 
-   git checkout -b rebased-feature-branch feature-branch 
-   test_when_finished git branch -D rebased-feature-branch 
+   test_when_finished rm -rf tmp 
+   (
+   setup_tmp 
echo dirty file3 
test_must_fail git rebase$type related-onto-branch 
test_path_is_file 

[PATCH v6 06/28] cherry-pick: store rewritten commits

2013-08-30 Thread Felipe Contreras
Will be useful for the next commits.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 sequencer.c | 22 +-
 sequencer.h |  1 +
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/sequencer.c b/sequencer.c
index d0e65de..468fa54 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -14,11 +14,13 @@
 #include merge-recursive.h
 #include refs.h
 #include argv-array.h
+#include rewrite.h
 
 #define GIT_REFLOG_ACTION GIT_REFLOG_ACTION
 
 const char sign_off_header[] = Signed-off-by: ;
 static const char cherry_picked_prefix[] = (cherry picked from commit ;
+static struct rewritten rewritten;
 
 static int is_rfc2822_line(const char *buf, int len)
 {
@@ -650,6 +652,14 @@ static int do_pick_commit(struct commit *commit, struct 
replay_opts *opts)
if (!opts-no_commit)
res = run_git_commit(defmsg, opts, allow);
 
+   if (!res  opts-action == REPLAY_PICK) {
+   unsigned char to[20];
+
+   if (read_ref(HEAD, to))
+   goto leave;
+
+   add_rewritten(rewritten, commit-object.sha1, to);
+   }
 leave:
free_message(msg);
free(defmsg);
@@ -1012,8 +1022,11 @@ static int pick_commits(struct commit_list *todo_list, 
struct replay_opts *opts)
for (cur = todo_list; cur; cur = cur-next) {
save_todo(cur, opts);
res = do_pick_commit(cur-item, opts);
-   if (res)
+   if (res) {
+   if (opts-action == REPLAY_PICK)
+   store_rewritten(rewritten, 
git_path(SEQ_REWR_FILE));
return res;
+   }
}
 
/*
@@ -1042,6 +1055,8 @@ static int sequencer_continue(struct replay_opts *opts)
return continue_single_pick();
read_populate_opts(opts);
read_populate_todo(todo_list, opts);
+   if (opts-action == REPLAY_PICK)
+   load_rewritten(rewritten, git_path(SEQ_REWR_FILE));
 
/* Verify that the conflict has been resolved */
if (file_exists(git_path(CHERRY_PICK_HEAD)) ||
@@ -1052,6 +1067,11 @@ static int sequencer_continue(struct replay_opts *opts)
}
if (index_differs_from(HEAD, 0))
return error_dirty_index(opts);
+   if (opts-action == REPLAY_PICK) {
+   unsigned char to[20];
+   if (!read_ref(HEAD, to))
+   add_rewritten(rewritten, todo_list-item-object.sha1, 
to);
+   }
todo_list = todo_list-next;
return pick_commits(todo_list, opts);
 }
diff --git a/sequencer.h b/sequencer.h
index 74d592a..efec1b5 100644
--- a/sequencer.h
+++ b/sequencer.h
@@ -5,6 +5,7 @@
 #define SEQ_HEAD_FILE  sequencer/head
 #define SEQ_TODO_FILE  sequencer/todo
 #define SEQ_OPTS_FILE  sequencer/opts
+#define SEQ_REWR_FILE  sequencer/rewritten
 
 #define APPEND_SIGNOFF_DEDUP (1u  0)
 
-- 
1.8.4-fc

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


[PATCH v6 17/28] rebase: cherry-pick: fix command invocations

2013-08-30 Thread Felipe Contreras
So that all the tests pass.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 git-rebase--cherrypick.sh | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/git-rebase--cherrypick.sh b/git-rebase--cherrypick.sh
index d8d32fe..e9e 100644
--- a/git-rebase--cherrypick.sh
+++ b/git-rebase--cherrypick.sh
@@ -21,7 +21,22 @@ test -n $rebase_root  root_flag=--root
 mkdir -p $state_dir || die Could not create temporary $state_dir
 :  $state_dir/cherrypick || die Could not mark as cherrypick
 
-git cherry-pick --allow-empty $revisions
+if test -n $rebase_root
+then
+   revisions=$onto...$orig_head
+else
+   revisions=$upstream...$orig_head
+fi
+
+if test -n $keep_empty
+then
+   extra=--allow-empty
+else
+   extra=--skip-empty --cherry-pick
+fi
+test -n $GIT_QUIET  extra=$extra -q
+test -z $force_rebase  extra=$extra --ff
+git cherry-pick --no-merges --right-only --topo-order --do-walk $extra 
$revisions
 ret=$?
 
 if test 0 != $ret
-- 
1.8.4-fc

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


[PATCH v6 09/28] builtin: rewrite: add copy_rewrite_notes()

2013-08-30 Thread Felipe Contreras
And use it on commit.c.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 builtin/commit.c |  8 +---
 rewrite.c| 18 ++
 rewrite.h|  1 +
 3 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/builtin/commit.c b/builtin/commit.c
index 7bfe9d0..cc589d5 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1621,16 +1621,10 @@ int cmd_commit(int argc, const char **argv, const char 
*prefix)
rerere(0);
run_hook(get_index_file(), post-commit, NULL);
if (amend  !no_post_rewrite) {
-   struct notes_rewrite_cfg *cfg;
struct rewritten rewrite;
memset(rewrite, 0, sizeof(rewrite));
-   cfg = init_copy_notes_for_rewrite(amend);
-   if (cfg) {
-   /* we are amending, so current_head is not NULL */
-   copy_note_for_rewrite(cfg, current_head-object.sha1, 
sha1);
-   finish_copy_notes_for_rewrite(cfg, Notes added by 'git 
commit --amend');
-   }
add_rewritten(rewrite, current_head-object.sha1, sha1);
+   copy_rewrite_notes(rewrite, amend, Notes added by 'git 
commit --amend');
run_rewrite_hook(rewrite, amend);
}
if (!quiet)
diff --git a/rewrite.c b/rewrite.c
index c8efaa8..4dddcd9 100644
--- a/rewrite.c
+++ b/rewrite.c
@@ -1,6 +1,7 @@
 #include cache.h
 #include rewrite.h
 #include run-command.h
+#include notes-utils.h
 
 void add_rewritten(struct rewritten *list, unsigned char *from, unsigned char 
*to)
 {
@@ -101,3 +102,20 @@ int run_rewrite_hook(struct rewritten *list, const char 
*name)
close(proc.in);
return finish_command(proc);
 }
+
+void copy_rewrite_notes(struct rewritten *list, const char *name, const char 
*msg)
+{
+   struct notes_rewrite_cfg *cfg;
+   int i;
+
+   cfg = init_copy_notes_for_rewrite(name);
+   if (!cfg)
+   return;
+
+   for (i = 0; i  list-nr; i++) {
+   struct rewritten_item *item = list-items[i];
+   copy_note_for_rewrite(cfg, item-from, item-to);
+   }
+
+   finish_copy_notes_for_rewrite(cfg, msg);
+}
diff --git a/rewrite.h b/rewrite.h
index fd00e66..fdc7055 100644
--- a/rewrite.h
+++ b/rewrite.h
@@ -15,5 +15,6 @@ void add_rewritten(struct rewritten *list, unsigned char 
*from, unsigned char *t
 int store_rewritten(struct rewritten *list, const char *file);
 void load_rewritten(struct rewritten *list, const char *file);
 int run_rewrite_hook(struct rewritten *list, const char *name);
+void copy_rewrite_notes(struct rewritten *list, const char *name, const char 
*msg);
 
 #endif
-- 
1.8.4-fc

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


Re: [PATCHv7 0/2] Rewriting repack in C

2013-08-30 Thread Stefan Beller
On 08/29/2013 10:53 PM, Junio C Hamano wrote:
 Stefan Beller stefanbel...@googlemail.com writes:
 
 Here is a diff since the last time sending this patch series:
 
 This is very readable.
 
 There may be people who misread LOOSE as LOSE; the option -A is 
 about making the unreachable ones loose so that they can be expired,
 so let's rename it LOOSEN_UNREACHABLE to avoid confusion.
 
 Thanks.
 

This would be very appreciated. I am no native speaker, so please
correct any variable naming, which could potentially be missleading.

I've seen you've already put a squashing proposal on top of
origin/sb/repack-in-c, it looks great, so feel free to squash it
into the first commit.

Thanks,
Stefan




signature.asc
Description: OpenPGP digital signature


Re: [PATCH] revision: add --except option

2013-08-30 Thread Felipe Contreras
On Fri, Aug 30, 2013 at 1:32 AM, Junio C Hamano gits...@pobox.com wrote:
 Felipe Contreras felipe.contre...@gmail.com writes:

 So that it's possible to remove certain refs from the list without
 removing the objects that are referenced by other refs.

 For example this repository:

   * 374e8dd (crap) crap
   * 4cbbf7b (test) two
   * d025ae0 (HEAD, master) one

 Can we make it more clear that your assumption is crap is a child
 of test which is a child of master?  Without that, the nothing
 will come out will not follow.

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

   * 4cbbf7b (test) two
   * d025ae0 (HEAD, master) one

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

 If you have a history where

  - branches master and maint point at commit A;
  - branch next points at commit B that is a descendant of A; and
  - there are tags X and Y pointing at commits that are ahead of B
or behind A

 i.e.

 XABY

 what are the desired semantics for these?

  (1) --branches --except maint

  (2) --all --not --branches --except maint

  (3) ^master next --except maint

 --branches wants to include master, next, and maint, and the
 --except tells us we do not want to take maint into account, but
 should that affect what master wants to do (either include or
 exclude what are reachable from it)?

No, it should not. '--branches --except main' becomes 'master next'.

 As the way we parse the revisions from the command line is to mark
 objects, not refs, as we go, it looks like that the flag SKIP in
 this patch is placed conceptually at a wrong level.

refs are marked as well.

 I agree --branches --except maint is a good concept, but to
 implement what this patch wants to do properly, I suspect that the
 revision parser may need to be extended to be a two-phase process;
 the first phase will collect list of objects involved in the range
 expression without marking them with UNINTERESTING mark (that would
 also involve expanding things like --all or --branches), while
 remembering those given with --except, exclude the except set from
 the first set, and then finally marking the objects using the
 remainder, or something like that.

That's not necessary, this patch does the trick.

 + ce = revs-cmdline.rev[i];
 + if ((ce-flags  SKIP)  !strcmp(ce-name, e-name))
 + goto next;

 I think this SKIP will not help an object that is already tainted by
 UNINTERESTING; if it is discovered during a traversal from another
 object that will remain in the rev-commits, the travesal will stop
 there, even if a ref that is marked with SKIP will goto next here.

No, the traversal will continue just fine. At this point we are still
not traversing anything, simply adding the heads that will need to be
traversed later on to a list. Whether this object has been tainted by
UNINTERESTED or not is irrelevant.

If you do 'master ^maint --except master', handle_commit will return
three commits:

master - ce-flags will have SKIP, nothing more happens
maint - ce-flags doesn't have SKIP, processing continues, and it's
added to the list of commits, the commit has UNINTERESTING, but that
doesn't matter
master - ce-flags will have SKIP, nothing more happens

Essentially it's the same as:

maint - it's added to the list of commits, the commit has UNINTERESTING

So, it's exactly the same as if you had typed '^maint', which is
exactly what we want.

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


Re: [PATCH] revision: add --except option

2013-08-30 Thread Felipe Contreras
On Fri, Aug 30, 2013 at 2:11 AM, Johannes Sixt j.s...@viscovery.net wrote:
 Am 8/30/2013 7:00, schrieb Felipe Contreras:
 So that it's possible to remove certain refs from the list without
 removing the objects that are referenced by other refs.

 For example this repository:

   * 374e8dd (crap) crap
   * 4cbbf7b (test) two
   * d025ae0 (HEAD, master) one

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

   * 4cbbf7b (test) two
   * d025ae0 (HEAD, master) one

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

 I like the idea to be able to exclude refs from listings. My use-case is
 the following:

 To unclutter 'git branch' output, I rename work-in-progress branches to
 begin with wip/, ready-to-merge branches do not carry this prefix. To
 inspect unmerged work of the latter kind of branches I would like to
 type... what?

   gitk --branches --except --branches=wip --not master
   gitk --branches --not master --except --branches=wip

 Would one of these work with your current patch?

The first one should work, but mostly by accident. A proper fix is not
far though:

diff --git a/revision.c b/revision.c
index 25564c1..1380cd1 100644
--- a/revision.c
+++ b/revision.c
@@ -1983,9 +1983,9 @@ static int handle_revision_pseudo_opt(const char
*submodule,
} else if (!strcmp(arg, --reflog)) {
handle_reflog(revs, *flags);
} else if (!strcmp(arg, --not)) {
-   *flags ^= UNINTERESTING | BOTTOM;
+   *flags = UNINTERESTING | BOTTOM;
} else if (!strcmp(arg, --except)) {
-   *flags ^= SKIP;
+   *flags = SKIP;
} else if (!strcmp(arg, --no-walk)) {
revs-no_walk = REVISION_WALK_NO_WALK_SORTED;
} else if (!prefixcmp(arg, --no-walk=)) {

Then both should work.

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


Re: [PATCH] revision: add --except option

2013-08-30 Thread Felipe Contreras
On Fri, Aug 30, 2013 at 2:26 AM, Junio C Hamano gits...@pobox.com wrote:
 Pardon terseness, typo and HTML from a tablet.


 On Aug 30, 2013 12:19 AM, Felipe Contreras felipe.contre...@gmail.com
 wrote:

 On Fri, Aug 30, 2013 at 1:32 AM, Junio C Hamano gits...@pobox.com wrote:
  Felipe Contreras felipe.contre...@gmail.com writes:
 
  So that it's possible to remove certain refs from the list without
  removing the objects that are referenced by other refs.
 
  For example this repository:
 
* 374e8dd (crap) crap
* 4cbbf7b (test) two
* d025ae0 (HEAD, master) one
 
  Can we make it more clear that your assumption is crap is a child
  of test which is a child of master?  Without that, the nothing
  will come out will not follow.
 
  When using '--branches --except crap':
 
* 4cbbf7b (test) two
* d025ae0 (HEAD, master) one
 
  But when using '--branches --not crap' nothing will come out.
 
  If you have a history where
 
   - branches master and maint point at commit A;
   - branch next points at commit B that is a descendant of A; and
   - there are tags X and Y pointing at commits that are ahead of B
 or behind A
 
  i.e.
 
  XABY
 
  what are the desired semantics for these?
 
   (1) --branches --except maint
 
   (2) --all --not --branches --except maint
 
   (3) ^master next --except maint
 
  --branches wants to include master, next, and maint, and the
  --except tells us we do not want to take maint into account, but
  should that affect what master wants to do (either include or
  exclude what are reachable from it)?

 No, it should not. '--branches --except main' becomes 'master next'.

  As the way we parse the revisions from the command line is to mark
  objects, not refs, as we go, it looks like that the flag SKIP in
  this patch is placed conceptually at a wrong level.

 refs are marked as well.

  I agree --branches --except maint is a good concept, but to
  implement what this patch wants to do properly, I suspect that the
  revision parser may need to be extended to be a two-phase process;
  the first phase will collect list of objects involved in the range
  expression without marking them with UNINTERESTING mark (that would
  also involve expanding things like --all or --branches), while
  remembering those given with --except, exclude the except set from
  the first set, and then finally marking the objects using the
  remainder, or something like that.

 That's not necessary, this patch does the trick.

  + ce = revs-cmdline.rev[i];
  + if ((ce-flags  SKIP)  !strcmp(ce-name,
  e-name))
  + goto next;
 
  I think this SKIP will not help an object that is already tainted by
  UNINTERESTING; if it is discovered during a traversal from another
  object that will remain in the rev-commits, the travesal will stop
  there, even if a ref that is marked with SKIP will goto next here.

 No, the traversal will continue just fine. At this point we are still
 not traversing anything, simply adding the heads that will need to be
 traversed later on to a list. Whether this object has been tainted by
 UNINTERESTED or not is irrelevant.

 If you do 'master ^maint --except master', handle_commit will return
 three commits:

 Would the same argument apply to

   next ^maint --except maint

 where next gets in the queue, maint in tainted, and skipped?

maint is not skipped, as it's not the same as ^maint, basically it's
the same as:

next ^maint

I think that's good, as there's absolutely no reason why anybody would
want '^maint --except maint' to cancel each other out.

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


Re: [PATCH] revision: add --except option

2013-08-30 Thread Johannes Sixt
Am 8/30/2013 8:32, schrieb Junio C Hamano:
 If you have a history where
 
  - branches master and maint point at commit A;
  - branch next points at commit B that is a descendant of A; and
  - there are tags X and Y pointing at commits that are ahead of B
or behind A
 
 i.e.
 
   XABY
 
 what are the desired semantics for these?

I think the simplest were that --except trumps everything and means
whatever else I say, do as if I did not mention the following.

  (1) --branches --except maint

= master next

  (2) --all --not --branches --except maint

= X Y --not master next

  (3) ^master next --except maint

= ^master next

What should the following mean? Does --not forget that --except was
earlier on the command line?

(4) Y next --except master next --not --branches

this = Y --not maint
or this = Y --not maint master next

What about this:

(5) --branches --except ^master

this = maint next
or this = maint master next ^master
or error(--except does not allow negated revisions)

-- Hannes
--
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] gitweb: Fix the author initials in blame for non-ASCII names

2013-08-30 Thread Ævar Arnfjörð Bjarmason
Change the @author_initials feature Jakub added in
v1.6.4-rc2-14-ga36817b to match non-ASCII author initials as intended.

The regexp Jakub added was intended to match
non-ASCII (/\b([[:upper:]])\B/g). But in Perl this doesn't actually
match non-ASCII upper-case characters unless the string being matched
against has the UTF8 flag.

So when we open a pipe to git blame we need to mark the file
descriptor we're opening as utf8 explicitly.

So as a result it abbreviates me to AB not ÆAB, entirely because Æ
isn't /[[:upper:]]/ unless the string being matched against has the UTF8
flag.

Here's something that demonstrates the issue:

#!/usr/bin/env perl
use strict;
use warnings;

binmode STDOUT, ':utf8' if $ENV{UTF8};
open my $fd, -|, git, blame, --incremental, --, Makefile or die 
Can't open: $!;
binmode $fd, :utf8 if $ENV{UTF8};
while (my $line = $fd) {
next unless my ($author) = $line =~ /^author (.*)/;
my @author_initials = ($author =~ /\b([[:upper:]])\B/g);
printf %s (%s)\n,  join(, @author_initials), $author;
}

When that's run with and without UTF8 being true in the environment it
gives, on git.git:

$ UTF8=0 perl author-initials.pl | sort | uniq -c |
sort -nr | head -n 5
 99 JH (Junio C Hamano)
 35 JN (Jonathan Nieder)
 35 JK (Jeff King)
 20 JS (Johannes Schindelin)
 16 AB (Ævar Arnfjörð Bjarmason)
$ UTF8=1 perl author-initials.pl | sort | uniq -c |
sort -nr | head -n 5
 99 JH (Junio C Hamano)
 35 JN (Jonathan Nieder)
 35 JK (Jeff King)
 20 JS (Johannes Schindelin)
 16 ÆAB (Ævar Arnfjörð Bjarmason)

Acked-by: Jakub Narębski jna...@gmail.com
Tested-by: Ævar Arnfjörð Bjarmason ava...@gmail.com
Tested-by: Simon Ruderich si...@ruderich.org
---
 gitweb/gitweb.perl | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index f429f75..ad48a5a 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -6631,6 +6631,7 @@ sub git_blame_common {
$hash_base, '--', $file_name
or die_error(500, Open git-blame --porcelain failed);
}
+   binmode $fh, ':utf8';
 
# incremental blame data returns early
if ($format eq 'data') {
-- 
1.8.4.rc2

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


[GIT PULL] hotfix on fr.po for the maint branch

2013-08-30 Thread Jiang Xin
Hi, Junio

Please merge this commit to the maint branch.

The following changes since commit e230c568c4b9a991e3175e5f65171a566fd8e39c:

  Git 1.8.4 (2013-08-23 11:49:46 -0700)

are available in the git repository at:

  git://github.com/git-l10n/git-po master

for you to fetch changes up to 21860882c8782771e99aa68fab6e365c628ff39d:

  l10n: fr.po: hotfix for commit 6b388fc (2013-08-30 16:59:29 +0800)


Sebastien Helleu (1):
  l10n: fr.po: hotfix for commit 6b388fc

 po/TEAMS |1 +
 po/fr.po | 1591 ++
 2 files changed, 874 insertions(+), 718 deletions(-)

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

2013-08-30 Thread Johannes Sixt
Am 8/30/2013 9:32, schrieb Felipe Contreras:
 On Fri, Aug 30, 2013 at 2:26 AM, Junio C Hamano gits...@pobox.com wrote:
 On Aug 30, 2013 12:19 AM, Felipe Contreras felipe.contre...@gmail.com
 Would the same argument apply to

   next ^maint --except maint

 where next gets in the queue, maint in tainted, and skipped?
 
 maint is not skipped, as it's not the same as ^maint, basically it's
 the same as:
 
 next ^maint
 
 I think that's good, as there's absolutely no reason why anybody would
 want '^maint --except maint' to cancel each other out.

But isn't this basically the same as '--not maint --except maint'? This by
itself looks strange. But when disguised in the form '--not --branches
--except maint', it would make sense to mean '--not master next', aka
'^master ^next'.

-- Hannes
--
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] git p4: implement view spec wildcards with p4 where

2013-08-30 Thread kazuki saitoh
Currently, git p4 does not support many of the view
wildcards, such as * and %%n.  It only knows the
common ... mapping, and exclusions.

Redo the entire wildcard code around the idea of
directly querying the p4 server for the mapping.  For each
commit, invoke p4 where with committed file paths as args and use
the client mapping to decide where the file goes in git.

This simplifies a lot of code, and adds support for all
wildcards supported by p4.
Downside is that there is probably a 20%-ish slowdown with this approach.

[pw: redo code and tests]

Signed-off-by: Kazuki Saitoh ksaitoh...@gmail.com
Signed-off-by: Pete Wyckoff p...@padd.com
---
 git-p4.py | 223 +-
 1 file changed, 59 insertions(+), 164 deletions(-)

diff --git a/git-p4.py b/git-p4.py
index 31e71ff..1793e86 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -780,11 +780,14 @@ def getClientSpec():
 # dictionary of all client parameters
 entry = specList[0]

+# the //client/ name
+client_name = entry[Client]
+
 # just the keys that start with View
 view_keys = [ k for k in entry.keys() if k.startswith(View) ]

 # hold this new View
-view = View()
+view = View(client_name)

 # append the lines, in order, to the view
 for view_num in range(len(view_keys)):
@@ -1555,8 +1558,8 @@ class P4Submit(Command, P4UserMap):
 for b in body:
 labelTemplate += \t + b + \n
 labelTemplate += View:\n
-for mapping in clientSpec.mappings:
-labelTemplate += \t%s\n % mapping.depot_side.path
+for depot_side in clientSpec.mappings:
+labelTemplate += \t%s\n % depot_side

 if self.dry_run:
 print Would create p4 label %s for tag % name
@@ -1568,7 +1571,7 @@ class P4Submit(Command, P4UserMap):

 # Use the label
 p4_system([tag, -l, name] +
-  [%s@%s % (mapping.depot_side.path,
changelist) for mapping in clientSpec.mappings])
+  [%s@%s % (depot_side, changelist) for
depot_side in clientSpec.mappings])

 if verbose:
 print created p4 label for tag %s % name
@@ -1796,117 +1799,16 @@ class View(object):
 Represent a p4 view (p4 help views), and map files in a
repo according to the view.

-class Path(object):
-A depot or client path, possibly containing wildcards.
-   The only one supported is ... at the end, currently.
-   Initialize with the full path, with //depot or //client.
-
-def __init__(self, path, is_depot):
-self.path = path
-self.is_depot = is_depot
-self.find_wildcards()
-# remember the prefix bit, useful for relative mappings
-m = re.match((//[^/]+/), self.path)
-if not m:
-die(Path %s does not start with //prefix/ % self.path)
-prefix = m.group(1)
-if not self.is_depot:
-# strip //client/ on client paths
-self.path = self.path[len(prefix):]
-
-def find_wildcards(self):
-Make sure wildcards are valid, and set up internal
-   variables.
-
-self.ends_triple_dot = False
-# There are three wildcards allowed in p4 views
-# (see p4 help views).  This code knows how to
-# handle ... (only at the end), but cannot deal with
-# %%n or *.  Only check the depot_side, as p4 should
-# validate that the client_side matches too.
-if re.search(r'%%[1-9]', self.path):
-die(Can't handle %%n wildcards in view: %s % self.path)
-if self.path.find(*) = 0:
-die(Can't handle * wildcards in view: %s % self.path)
-triple_dot_index = self.path.find(...)
-if triple_dot_index = 0:
-if triple_dot_index != len(self.path) - 3:
-die(Can handle only single ... wildcard, at end: %s %
-self.path)
-self.ends_triple_dot = True
-
-def ensure_compatible(self, other_path):
-Make sure the wildcards agree.
-if self.ends_triple_dot != other_path.ends_triple_dot:
- die(Both paths must end with ... if either does;\n +
- paths: %s %s % (self.path, other_path.path))
-
-def match_wildcards(self, test_path):
-See if this test_path matches us, and fill in the value
-   of the wildcards if so.  Returns a tuple of
-   (True|False, wildcards[]).  For now, only the ... at end
-   is supported, so at most one wildcard.
-if self.ends_triple_dot:
-dotless = self.path[:-3]
-if test_path.startswith(dotless):
-wildcard = test_path[len(dotless):]
-

[PATCH] fix shell syntax error in template

2013-08-30 Thread Thorsten Glaser
an if clause must not be empty; add a colon command

Signed-off-by: Thorsten Glaser t.gla...@tarent.de
---
 templates/hooks--pre-push.sample | 1 +
 1 file changed, 1 insertion(+)

diff --git a/templates/hooks--pre-push.sample b/templates/hooks--pre-push.sample
index 15ab6d8..1f3bceb 100755
--- a/templates/hooks--pre-push.sample
+++ b/templates/hooks--pre-push.sample
@@ -30,6 +30,7 @@ do
if [ $local_sha = $z40 ]
then
# Handle delete
+   :
else
if [ $remote_sha = $z40 ]
then
-- 
1.8.4.rc3

--
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: Stalled git cloning and possible solutions

2013-08-30 Thread Duy Nguyen
On Fri, Aug 30, 2013 at 4:10 AM, Jonathan Nieder jrnie...@gmail.com wrote:
 V.Krishn wrote:

 Quite sometimes when cloning a large repo stalls, hitting Ctrl+c cleans what
 been downloaded, and process needs re-start.

 Is there a way to recover or continue from already downloaded files during
 cloning ?

 No, sadly.  The pack sent for a clone is generated dynamically, so
 there's no easy way to support the equivalent of an HTTP Range request
 to resume.  Someone might implement an appropriate protocol extension
 to tackle this (e.g., peff's seed-with-clone.bundle hack) some day,
 but for now it doesn't exist.

OK how about a new capability resume to upload-pack. fetch-pack can
then send capability resume[=SHA-1,skip] to upload-pack. The
first time it sends resume without parameters, and upload-pack will
send back an SHA-1 to identify the pack being transferred together
with a full pack as usual. When early disconnection happens, it sends
the received SHA-1 and the received pack's size so far. It either
receives the remaining part, or a full pack.

When upload-pack gets resume, it calculates a checksum of all input
that may impact pack generation. If the checksum matches the SHA-1
from fetch-pack, it'll continue to generate the pack as usual, but
will skip sending the first skip bytes (maybe with a fake header so
that fetch-pack realizes this is a partial pack). If the checksum does
not match, it sends full pack again. I count on index-pack to spot
corrupt resumed pack due to bugs.

The input to calculate SHA-1 checksum includes:

 - the result SHA-1 list from rev-list
 - git version string
 - .git/shallow
 - replace object database
 - pack.* config
 - maybe some other variables (I haven't checked pack-objects)

Another Git implementation can generate this SHA-1 in a totally
different way and may even cache the generated pack.

If at resume time, the load balancer directs the request to another
upload-pack that generates this SHA-1 differently, ok this won't work
(i.e. full pack is returned). In a busy repository, some refs may have
moved so rev-list result at the resume time won't match any more, but
we can deal with that later by relaxing to allow want  lines with
SHA-1 that are reachable from current refs, not just one of the refs
(pack v4 or reachability bitmaps help).
-- 
Duy
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] remote: filter out invalid remote configurations

2013-08-30 Thread Carlos Martín Nieto
On Tue, 2013-08-27 at 07:50 -0700, Junio C Hamano wrote:
 Carlos Martín Nieto c...@elego.de writes:
 
  In remote's configuration callback, anything that looks like
  'remote.name.*' creates a remote 'name'. This remote may not end
  up having any configuration for a remote, but it's still in the list,
  so 'git remote' shows it, which means something like
 
  [remote bogus]
  hocus = pocus
 
  will show a remote 'bogus' in the listing, even though it won't work
  as a remote name for either git-fetch or git-push.
 
 Isn't this something the user may want to be aware of, though?
 Hiding these would rob a chance for such an entry to be noticed from
 the user---is it a good change?

If we want to help the user know that there's something a bit odd in
their configuration, shouldn't we tell them instead of hoping they
stumble upon it? Otherwise IMO it's more confusing if git-remote does
show the remote when git-fetch is interpreting the argument as a path.

   cmn



--
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: Stalled git cloning and possible solutions

2013-08-30 Thread Duy Nguyen
On Fri, Aug 30, 2013 at 7:17 PM, Duy Nguyen pclo...@gmail.com wrote:
 OK how about a new capability resume to upload-pack. fetch-pack can
 then send capability resume[=SHA-1,skip] to upload-pack. The
 first time it sends resume without parameters, and upload-pack will
 send back an SHA-1 to identify the pack being transferred together
 with a full pack as usual. When early disconnection happens, it sends
 the received SHA-1 and the received pack's size so far. It either
 receives the remaining part, or a full pack.

 When upload-pack gets resume, it calculates a checksum of all input
 that may impact pack generation. If the checksum matches the SHA-1
 from fetch-pack, it'll continue to generate the pack as usual, but
 will skip sending the first skip bytes (maybe with a fake header so
 that fetch-pack realizes this is a partial pack). If the checksum does
 not match, it sends full pack again. I count on index-pack to spot
 corrupt resumed pack due to bugs.

 The input to calculate SHA-1 checksum includes:

  - the result SHA-1 list from rev-list
  - git version string
  - .git/shallow
  - replace object database
  - pack.* config
  - maybe some other variables (I haven't checked pack-objects)

should have tested something first before I wrote. --threads adds some
randomness to pack generation so it has to be --threads=1. Not sure if
git repository hosts are happy with it..

 Another Git implementation can generate this SHA-1 in a totally
 different way and may even cache the generated pack.

 If at resume time, the load balancer directs the request to another
 upload-pack that generates this SHA-1 differently, ok this won't work
 (i.e. full pack is returned). In a busy repository, some refs may have
 moved so rev-list result at the resume time won't match any more, but
 we can deal with that later by relaxing to allow want  lines with
 SHA-1 that are reachable from current refs, not just one of the refs
 (pack v4 or reachability bitmaps help).
 --
 Duy



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


[PATCH] Teach git to change to a given directory using -C option

2013-08-30 Thread Nazri Ramliy
This is similar in spirit to to make -C dir ... and tar -C dir 

Currently it takes more effort (keypresses) to invoke git command in a
different directory than the current one without leaving the current
directory:

1. (cd ~/foo  git status)
   git --git-dir=~/foo/.git --work-dir=~/foo status
   GIT_DIR=~/foo/.git GIT_WORK_TREE=~/foo git status
2. (cd ../..; git grep foo)
3. for d in d1 d2 d3; do (cd $d  git svn rebase); done

While doable the methods shown above are arguably more suitable for
scripting than quick command line invocations.

With this new option, the above can be done with less keystrokes:

1. git -C ~/foo status
2. git -C ../.. grep foo
3. for d in d1 d2 d3; do git -C $d svn rebase; done

A new test script is added to verify the behavior of this option with
other path-related options like --git-dir and --work-tree.

Signed-off-by: Nazri Ramliy ayieh...@gmail.com
---
This is a reroll of [1]. The only difference is the rewording of the
commit message.  I'm resending this as I've found it to be useful in my
daily git usage in that it helps me stay focused on what I'm doing in
the current directory while needing to run git on another directory.

nazri.

[1] http://permalink.gmane.org/gmane.comp.version-control.git/221954

 Documentation/git.txt | 13 +
 git.c | 15 --
 t/t0056-git-C.sh  | 76 +++
 3 files changed, 102 insertions(+), 2 deletions(-)
 create mode 100755 t/t0056-git-C.sh

diff --git a/Documentation/git.txt b/Documentation/git.txt
index dca11cc..0d44fa2 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -395,6 +395,19 @@ displayed. See linkgit:git-help[1] for more information,
 because `git --help ...` is converted internally into `git
 help ...`.
 
+-C directory::
+   Run as if git were started in directory instead of the current
+   working directory. If multiple -C options are given, subsequent
+   directory arguments are interpreted relative to the previous one: -C
+   /usr -C src is equivalent to -C /usr/src. This option affects options
+   that expect path name like --git-dir and --work-tree in that their
+   interpretations of the path names would be made relative to the
+   effective working directory caused by the -C option. For example the
+   following invocations are equivalent:
+
+   git --git-dir=a.git --work-tree=b -C c status
+   git --git-dir=c/a.git --work-tree=c/b status
+
 -c name=value::
Pass a configuration parameter to the command. The value
given will override values from configuration files.
diff --git a/git.c b/git.c
index 2025f77..2207ee5 100644
--- a/git.c
+++ b/git.c
@@ -7,7 +7,7 @@
 #include commit.h
 
 const char git_usage_string[] =
-   git [--version] [--help] [-c name=value]\n
+   git [--version] [--help] [-C directory] [-c name=value]\n
   [--exec-path[=path]] [--html-path] [--man-path] 
[--info-path]\n
   [-p|--paginate|--no-pager] [--no-replace-objects] 
[--bare]\n
   [--git-dir=path] [--work-tree=path] 
[--namespace=name]\n
@@ -54,7 +54,18 @@ static int handle_options(const char ***argv, int *argc, int 
*envchanged)
/*
 * Check remaining flags.
 */
-   if (!prefixcmp(cmd, --exec-path)) {
+   if (!strcmp(cmd, -C)) {
+   if (*argc  2) {
+   fprintf(stderr, No directory given for -C.\n 
);
+   usage(git_usage_string);
+   }
+   if (chdir((*argv)[1]))
+   die_errno(Cannot change to '%s', (*argv)[1]);
+   if (envchanged)
+   *envchanged = 1;
+   (*argv)++;
+   (*argc)--;
+   } else if (!prefixcmp(cmd, --exec-path)) {
cmd += 11;
if (*cmd == '=')
git_set_argv_exec_path(cmd + 1);
diff --git a/t/t0056-git-C.sh b/t/t0056-git-C.sh
new file mode 100755
index 000..370eae6
--- /dev/null
+++ b/t/t0056-git-C.sh
@@ -0,0 +1,76 @@
+#!/bin/sh
+
+test_description='-C directory option and it effects on other path-related 
options'
+
+. ./test-lib.sh
+
+test_expect_success 'git -C dir runs git from the directory dir' '
+   test_create_repo dir1 
+   echo 1 dir1/a.txt 
+   (cd dir1  git add a.txt  git commit -m initial in dir1) 
+   expected=initial in dir1 
+   actual=$(git -C dir1 log --format=%s) 
+   test $expected = $actual
+'
+
+test_expect_success 'Multiple -C options: -C dir1 -C dir2 is equivalent to 
-C dir1/dir2' '
+   test_create_repo dir1/dir2 
+   echo 1 dir1/dir2/a.txt 
+   git -C dir1/dir2 add a.txt 
+   expected=initial in dir1/dir2 
+   git -C dir1/dir2 commit -m 

Re: [PATCH] revision: add --except option

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

 If you do 'master ^maint --except master', handle_commit will return
 three commits:

 Would the same argument apply to

   next ^maint --except maint

 where next gets in the queue, maint in tainted, and skipped?

 maint is not skipped, as it's not the same as ^maint, basically it's
 the same as:

 next ^maint

 I think that's good, as there's absolutely no reason why anybody would
 want '^maint --except maint' to cancel each other out.

I do not expect anybody to say ^maint --except maint, but the
negative one can come from expansion of --branches and such.
Essentially, the semantics the patch implements is --except applies
only to positive tips (I have not thought about its implications on
left-right traversals; there may be some impact there as well).

Being able to exclude only positive ones is better than not being
able to exclude any, but if we consider j6t's example, I think
applying except to negative ones is equally useful.

For example, I want to see everything I have reachable from my refs
(not just branches), but exclude those that are reachable from my
stable branches (my local branches except those whose names match
the pattern 'wip/*') is a reasonable thing to ask.  A wip/* branch
may be based on the work in a remote tracking branch that you have
not merged to your 'maint', 'master' or 'next', and you want to view
all the commits on the remote tracking branch you haven't merged to
your stable branches, including the ones that you already use in
your WIP that are not ready.  And the request may be spelled as

--all --not --branches --except 'wip/*'

Which means that the approach taken by the patch to only allow
exclusion of negative ones makes the idea only 50% useful compared
to its potential.  And I suspect that we can start from 50% which
is better than 0% and later fill the other 50% would not work in
this case, without ripping out the SKIP on object approach and
redoing the --except support from scratch, because SKIP on
object fundamentally cannot undo the effects of the negative ones,
because it records the information at a wrong level.

It may be a good idea to step back a bit and think of this topic as
a way to enhance the --branches option and its friends with only the
inclusive wildcard semantics.  It lets us include those that match
the pattern with --branches=wip/*, but there is no way to say oh
by the way, I do not want those that match this pattern included
when you expand this short-hand.  We have --branches=pattern that
is inclusive; perhaps it can be prefixed with --branches=!pattern to
pre-declare whatever the next --branches expands to, do not include
those that match this pattern, or something, which would make the
earlier wip example to be:

--all --not --branches='!wip/*' --branches

--
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] remote: filter out invalid remote configurations

2013-08-30 Thread Junio C Hamano
Carlos Martín Nieto c...@elego.de writes:

 On Tue, 2013-08-27 at 07:50 -0700, Junio C Hamano wrote:
 Carlos Martín Nieto c...@elego.de writes:
 
  In remote's configuration callback, anything that looks like
  'remote.name.*' creates a remote 'name'. This remote may not end
  up having any configuration for a remote, but it's still in the list,
  so 'git remote' shows it, which means something like
 
  [remote bogus]
  hocus = pocus
 
  will show a remote 'bogus' in the listing, even though it won't work
  as a remote name for either git-fetch or git-push.
 
 Isn't this something the user may want to be aware of, though?
 Hiding these would rob a chance for such an entry to be noticed from
 the user---is it a good change?

 If we want to help the user know that there's something a bit odd in
 their configuration, shouldn't we tell them instead of hoping they
 stumble upon it?

Yeah, I agree that git remote that tells the above bogus is
fishy is better than just hides it.



--
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 PULL] hotfix on fr.po for the maint branch

2013-08-30 Thread Junio C Hamano
Jiang Xin worldhello@gmail.com writes:

 Please merge this commit to the maint branch.

 The following changes since commit e230c568c4b9a991e3175e5f65171a566fd8e39c:

   Git 1.8.4 (2013-08-23 11:49:46 -0700)

 are available in the git repository at:

   git://github.com/git-l10n/git-po master

 for you to fetch changes up to 21860882c8782771e99aa68fab6e365c628ff39d:

   l10n: fr.po: hotfix for commit 6b388fc (2013-08-30 16:59:29 +0800)

 
 Sebastien Helleu (1):
   l10n: fr.po: hotfix for commit 6b388fc

Hmph, what happened that requires a hotfix to message strings?


  po/TEAMS |1 +
  po/fr.po | 1591 
 ++
  2 files changed, 874 insertions(+), 718 deletions(-)

 --
 Jiang Xin
--
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 PULL] hotfix on fr.po for the maint branch

2013-08-30 Thread Jean-Noël AVILA
Le vendredi 30 août 2013 09:54:59 Junio C Hamano a écrit :
 Jiang Xin worldhello@gmail.com writes:
  Please merge this commit to the maint branch.
  
  The following changes since commit 
e230c568c4b9a991e3175e5f65171a566fd8e39c:
Git 1.8.4 (2013-08-23 11:49:46 -0700)
  
  are available in the git repository at:
git://github.com/git-l10n/git-po master
  
  for you to fetch changes up to 21860882c8782771e99aa68fab6e365c628ff39d:
l10n: fr.po: hotfix for commit 6b388fc (2013-08-30 16:59:29 +0800)
  
  
  
  Sebastien Helleu (1):
l10n: fr.po: hotfix for commit 6b388fc
 
 Hmph, what happened that requires a hotfix to message strings?

Well, as the author of the first commit,, I must say that the quality was not 
good. But it became visible and hooked up a reviewer only when it was promoted 
to stable version...

There are some strings that do not make sense in the usage pages, a missing %s 
in one. Agreed that applying this patch does not solve a critical 
issue, but 
it is low risk.

 
   po/TEAMS |1 +
   po/fr.po | 1591
   ++ 2 files
   changed, 874 insertions(+), 718 deletions(-)
  
  --
  Jiang Xin
--
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 PULL] hotfix on fr.po for the maint branch

2013-08-30 Thread Junio C Hamano
Jean-Noël AVILA jn.av...@free.fr writes:

 Le vendredi 30 août 2013 09:54:59 Junio C Hamano a écrit :
 Jiang Xin worldhello@gmail.com writes:
  Please merge this commit to the maint branch.
  
  The following changes since commit 
 e230c568c4b9a991e3175e5f65171a566fd8e39c:
Git 1.8.4 (2013-08-23 11:49:46 -0700)
  
  are available in the git repository at:
git://github.com/git-l10n/git-po master
  
  for you to fetch changes up to 21860882c8782771e99aa68fab6e365c628ff39d:
l10n: fr.po: hotfix for commit 6b388fc (2013-08-30 16:59:29 +0800)
  
  
  
  Sebastien Helleu (1):
l10n: fr.po: hotfix for commit 6b388fc
 
 Hmph, what happened that requires a hotfix to message strings?

 Well, as the author of the first commit,, I must say that the quality was not 
 good. But it became visible and hooked up a reviewer only when it was 
 promoted 
 to stable version...

 There are some strings that do not make sense in the usage pages, a missing 
 %s 
 in one.   Agreed that applying this patch does not solve a critical 
 issue, but 
 it is low risk.

OK, I was just reacting to the hotfix wording and wondering the
level of urgency.  Will pull to maint later before cutting 1.8.4.1.

Thanks.


 
   po/TEAMS |1 +
   po/fr.po | 1591
   ++ 2 files
   changed, 874 insertions(+), 718 deletions(-)
  
  --
  Jiang Xin
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 0/8] Multiple simultaneously locked ref updates

2013-08-30 Thread Brad King
Hi Folks,

Here is the second revision of a series to support locking multiple
refs at the same time to update all of them consistently.  The first
series can be found at $gmane/233260.  This revision is ready to
consider for integration.

Updates since the previous revision of the series:

* Incorporated style fixes and cleanups suggested by Junio.

* In patch 6, the new update_refs function now sorts the updates
  so that locks are acquired in a consistent order by competing
  processes.  Then it uses a simple linear scan to reject input
  containing duplicate refs (which are adjacent after sorting).
  Also, struct ref_update now has a symmetric representation
  for new_sha1 and old_sha1.

* In patch 7, I propose a new format for instructions read from
  standard input that is much more robust and extensible.

* Patch 8 is new and adds test cases covering new features
  and error cases.

-Brad

Brad King (8):
  reset: rename update_refs to reset_refs
  refs: report ref type from lock_any_ref_for_update
  refs: factor update_ref steps into helpers
  refs: factor delete_ref loose ref step into a helper
  refs: add function to repack without multiple refs
  refs: add update_refs for multiple simultaneous updates
  update-ref: support multiple simultaneous updates
  update-ref: add test cases covering --stdin signature

 Documentation/git-update-ref.txt |   21 +++-
 branch.c |2 +-
 builtin/commit.c |2 +-
 builtin/fetch.c  |3 +-
 builtin/receive-pack.c   |3 +-
 builtin/reflog.c |2 +-
 builtin/replace.c|2 +-
 builtin/reset.c  |4 +-
 builtin/tag.c|2 +-
 builtin/update-ref.c |  121 +-
 fast-import.c|2 +-
 refs.c   |  203 +
 refs.h   |   16 ++-
 sequencer.c  |3 +-
 t/t1400-update-ref.sh|  206 ++
 15 files changed, 558 insertions(+), 34 deletions(-)

-- 
1.7.10.4

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


[PATCH v2 1/8] reset: rename update_refs to reset_refs

2013-08-30 Thread Brad King
The function resets refs rather than doing arbitrary updates.
Rename it to allow a future general-purpose update_refs function
to be added.

Signed-off-by: Brad King brad.k...@kitware.com
---
 builtin/reset.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin/reset.c b/builtin/reset.c
index afa6e02..789ee48 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -219,7 +219,7 @@ static const char **parse_args(const char **argv, const 
char *prefix, const char
return argv[0] ? get_pathspec(prefix, argv) : NULL;
 }
 
-static int update_refs(const char *rev, const unsigned char *sha1)
+static int reset_refs(const char *rev, const unsigned char *sha1)
 {
int update_ref_status;
struct strbuf msg = STRBUF_INIT;
@@ -350,7 +350,7 @@ int cmd_reset(int argc, const char **argv, const char 
*prefix)
if (!pathspec  !unborn) {
/* Any resets without paths update HEAD to the head being
 * switched to, saving the previous head in ORIG_HEAD before. */
-   update_ref_status = update_refs(rev, sha1);
+   update_ref_status = reset_refs(rev, sha1);
 
if (reset_type == HARD  !update_ref_status  !quiet)
print_new_head_line(lookup_commit_reference(sha1));
-- 
1.7.10.4

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


Re: [PATCH] gitweb: Fix the author initials in blame for non-ASCII names

2013-08-30 Thread Junio C Hamano
Junio C Hamano gits...@pobox.com writes:

 Ævar Arnfjörð Bjarmason  ava...@gmail.com writes:

 Acked-by: Jakub Narębski jna...@gmail.com
 Tested-by: Ævar Arnfjörð Bjarmason ava...@gmail.com
 Tested-by: Simon Ruderich si...@ruderich.org
 ---
 +++ b/gitweb/gitweb.perl
 @@ -6631,6 +6631,7 @@ sub git_blame_common {
 ...
 +binmode $fh, ':utf8';


 [Fri Aug 30 17:48:17 2013] gitweb.perl: Global symbol $fh requires
 explicit package name at 
 /home/gitster/w/buildfarm/next/t/../gitweb/gitweb.perl line 6634.
 [Fri Aug 30 17:48:17 2013] gitweb.perl: Execution of 
 /home/gitster/w/buildfarm/next/t/../gitweb/gitweb.perl aborted due to 
 compilation errors.

I think in this function the filehandle is called $fd, not $fh.  Has
any of you really tested this???
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 8/8] update-ref: add test cases covering --stdin signature

2013-08-30 Thread Brad King
Extend t/t1400-update-ref.sh to cover cases using the --stdin option.

Signed-off-by: Brad King brad.k...@kitware.com
---
 t/t1400-update-ref.sh |  206 +
 1 file changed, 206 insertions(+)

diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
index e415ee0..9fd03fc 100755
--- a/t/t1400-update-ref.sh
+++ b/t/t1400-update-ref.sh
@@ -302,4 +302,210 @@ test_expect_success \
'git cat-file blob master@{2005-05-26 23:42}:F (expect OTHER)' \
'test OTHER = $(git cat-file blob master@{2005-05-26 23:42}:F)'
 
+a=refs/heads/a
+b=refs/heads/b
+c=refs/heads/c
+z=
+e=''
+
+test_expect_success 'stdin works with no input' '
+   rm -f stdin 
+   touch stdin 
+   git update-ref --stdin  stdin 
+   git rev-parse --verify -q $m
+'
+
+test_expect_success 'stdin fails with bad line lines' '
+   echostdin 
+   test_must_fail git update-ref --stdin  stdin 2 err 
+   grep fatal: no ref on line:   err 
+   echo --  stdin 
+   test_must_fail git update-ref --stdin  stdin 2 err 
+   grep fatal: no ref on line: -- err 
+   echo --bad-option  stdin 
+   test_must_fail git update-ref --stdin  stdin 2 err 
+   grep fatal: unknown option --bad-option err 
+   echo -\''' $a $m  stdin 
+   test_must_fail git update-ref --stdin  stdin 2 err 
+   grep fatal: unknown option -''' err 
+   echo ~a $m  stdin 
+   test_must_fail git update-ref --stdin  stdin 2 err 
+   grep fatal: invalid ref format on line: ~a $m err 
+   echo $a '''master  stdin 
+   test_must_fail git update-ref --stdin  stdin 2 err 
+   grep fatal: unterminated single-quote: '''master err 
+   echo $a \master  stdin 
+   test_must_fail git update-ref --stdin  stdin 2 err 
+   grep fatal: unquoted backslash not escaping single-quote: master 
err 
+   echo $a $m $m $m  stdin 
+   test_must_fail git update-ref --stdin  stdin 2 err 
+   grep fatal: too many arguments on line: $a $m $m $m err 
+   echo $a  stdin 
+   test_must_fail git update-ref --stdin  stdin 2 err 
+   grep fatal: missing new value on line: $a err
+'
+
+test_expect_success 'stdin fails with duplicate refs' '
+   echo $a $m  stdin 
+   echo $b $m  stdin 
+   echo $a $m  stdin 
+   test_must_fail git update-ref --stdin  stdin 2 err 
+   grep fatal: Multiple updates for ref '''$a''' not allowed. err
+'
+
+test_expect_success 'stdin create ref works with no old value' '
+   echo $a $m  stdin 
+   git update-ref --stdin  stdin 
+   git rev-parse $m  expect 
+   git rev-parse $a  actual 
+   test_cmp expect actual
+'
+
+test_expect_success 'stdin create ref works with zero old value' '
+   echo $b $m $z  stdin 
+   git update-ref --stdin  stdin 
+   git rev-parse $m  expect 
+   git rev-parse $b  actual 
+   test_cmp expect actual 
+   git update-ref -d $b 
+   echo $b $m $e  stdin 
+   git update-ref --stdin  stdin 
+   git rev-parse $m  expect 
+   git rev-parse $b  actual 
+   test_cmp expect actual
+'
+
+test_expect_success 'stdin create ref fails with wrong old value' '
+   echo $c $m $m~1  stdin 
+   test_must_fail git update-ref --stdin  stdin 2 err 
+   grep fatal: Cannot lock the ref '''$c''' err 
+   test_must_fail git rev-parse --verify -q $c
+'
+
+test_expect_success 'stdin create ref fails with bad old value' '
+   echo $c $m does-not-exist  stdin 
+   test_must_fail git update-ref --stdin  stdin 2 err 
+   grep fatal: invalid old value on line: $c $m does-not-exist err 
+   test_must_fail git rev-parse --verify -q $c
+'
+
+test_expect_success 'stdin create ref fails with bad new value' '
+   echo $c does-not-exist  stdin 
+   test_must_fail git update-ref --stdin  stdin 2 err 
+   grep fatal: invalid new value on line: $c does-not-exist err 
+   test_must_fail git rev-parse --verify -q $c
+'
+
+test_expect_success 'stdin update ref works with right old value' '
+   echo $b $m~1 $m  stdin 
+   git update-ref --stdin  stdin 
+   git rev-parse $m~1  expect 
+   git rev-parse $b  actual 
+   test_cmp expect actual
+'
+
+test_expect_success 'stdin update ref fails with wrong old value' '
+   echo $b $m~1 $m  stdin 
+   test_must_fail git update-ref --stdin  stdin 2 err 
+   grep fatal: Cannot lock the ref '''$b''' err 
+   git rev-parse $m~1  expect 
+   git rev-parse $b  actual 
+   test_cmp expect actual
+'
+
+test_expect_success 'stdin delete ref fails with wrong old value' '
+   echo $a $e $m~1  stdin 
+   test_must_fail git update-ref --stdin  stdin 2 err 
+   grep fatal: Cannot lock the ref '''$a''' err 
+   git rev-parse $m  expect 
+   git rev-parse $a  actual 
+   test_cmp expect actual
+'
+
+test_expect_success 'stdin update symref works with --no-deref' '
+   

[PATCH v2 4/8] refs: factor delete_ref loose ref step into a helper

2013-08-30 Thread Brad King
Factor loose ref deletion into helper function delete_ref_loose to allow
later use elsewhere.

Signed-off-by: Brad King brad.k...@kitware.com
---
 refs.c |   22 +++---
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/refs.c b/refs.c
index 2e755b4..5dd86ee 100644
--- a/refs.c
+++ b/refs.c
@@ -2450,14 +2450,9 @@ static int repack_without_ref(const char *refname)
return commit_packed_refs();
 }
 
-int delete_ref(const char *refname, const unsigned char *sha1, int delopt)
+static int delete_ref_loose(struct ref_lock *lock, int flag)
 {
-   struct ref_lock *lock;
-   int err, i = 0, ret = 0, flag = 0;
-
-   lock = lock_ref_sha1_basic(refname, sha1, delopt, flag);
-   if (!lock)
-   return 1;
+   int err, i, ret = 0;
if (!(flag  REF_ISPACKED) || flag  REF_ISSYMREF) {
/* loose */
i = strlen(lock-lk-filename) - 5; /* .lock */
@@ -2468,6 +2463,19 @@ int delete_ref(const char *refname, const unsigned char 
*sha1, int delopt)
 
lock-lk-filename[i] = '.';
}
+   return ret;
+}
+
+int delete_ref(const char *refname, const unsigned char *sha1, int delopt)
+{
+   struct ref_lock *lock;
+   int ret = 0, flag = 0;
+
+   lock = lock_ref_sha1_basic(refname, sha1, delopt, flag);
+   if (!lock)
+   return 1;
+   ret |= delete_ref_loose(lock, flag);
+
/* removing the loose one could have resurrected an earlier
 * packed one.  Also, if it was not loose we need to repack
 * without it.
-- 
1.7.10.4

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


[PATCH v2 3/8] refs: factor update_ref steps into helpers

2013-08-30 Thread Brad King
Factor the lock and write steps and error handling into helper functions
update_ref_lock and update_ref_write to allow later use elsewhere.
Expose lock_any_ref_for_update's type_p to update_ref_lock callers.

Signed-off-by: Brad King brad.k...@kitware.com
---
 refs.c |   28 +++-
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/refs.c b/refs.c
index c69fd68..2e755b4 100644
--- a/refs.c
+++ b/refs.c
@@ -3170,12 +3170,13 @@ int for_each_reflog(each_ref_fn fn, void *cb_data)
return retval;
 }
 
-int update_ref(const char *action, const char *refname,
-   const unsigned char *sha1, const unsigned char *oldval,
-   int flags, enum action_on_err onerr)
+static struct ref_lock *update_ref_lock(const char *refname,
+   const unsigned char *oldval,
+   int flags, int *type_p,
+   enum action_on_err onerr)
 {
static struct ref_lock *lock;
-   lock = lock_any_ref_for_update(refname, oldval, flags, NULL);
+   lock = lock_any_ref_for_update(refname, oldval, flags, type_p);
if (!lock) {
const char *str = Cannot lock the ref '%s'.;
switch (onerr) {
@@ -3183,8 +3184,14 @@ int update_ref(const char *action, const char *refname,
case DIE_ON_ERR: die(str, refname); break;
case QUIET_ON_ERR: break;
}
-   return 1;
}
+   return lock;
+}
+
+static int update_ref_write(const char *action, const char *refname,
+   const unsigned char *sha1, struct ref_lock *lock,
+   enum action_on_err onerr)
+{
if (write_ref_sha1(lock, sha1, action)  0) {
const char *str = Cannot update the ref '%s'.;
switch (onerr) {
@@ -3197,6 +3204,17 @@ int update_ref(const char *action, const char *refname,
return 0;
 }
 
+int update_ref(const char *action, const char *refname,
+  const unsigned char *sha1, const unsigned char *oldval,
+  int flags, enum action_on_err onerr)
+{
+   static struct ref_lock *lock;
+   lock = update_ref_lock(refname, oldval, flags, 0, onerr);
+   if (!lock)
+   return 1;
+   return update_ref_write(action, refname, sha1, lock, onerr);
+}
+
 struct ref *find_ref_by_name(const struct ref *list, const char *name)
 {
for ( ; list; list = list-next)
-- 
1.7.10.4

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


[PATCH v2 2/8] refs: report ref type from lock_any_ref_for_update

2013-08-30 Thread Brad King
Expose lock_ref_sha1_basic's type_p argument to callers of
lock_any_ref_for_update.  Update all call sites to ignore it by passing
NULL for now.

Signed-off-by: Brad King brad.k...@kitware.com
---
 branch.c   |2 +-
 builtin/commit.c   |2 +-
 builtin/fetch.c|3 ++-
 builtin/receive-pack.c |3 ++-
 builtin/reflog.c   |2 +-
 builtin/replace.c  |2 +-
 builtin/tag.c  |2 +-
 fast-import.c  |2 +-
 refs.c |7 ---
 refs.h |2 +-
 sequencer.c|3 ++-
 11 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/branch.c b/branch.c
index c5c6984..f2d383f 100644
--- a/branch.c
+++ b/branch.c
@@ -291,7 +291,7 @@ void create_branch(const char *head,
hashcpy(sha1, commit-object.sha1);
 
if (!dont_change_ref) {
-   lock = lock_any_ref_for_update(ref.buf, NULL, 0);
+   lock = lock_any_ref_for_update(ref.buf, NULL, 0, NULL);
if (!lock)
die_errno(_(Failed to lock ref for update));
}
diff --git a/builtin/commit.c b/builtin/commit.c
index 10acc53..be08f41 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1618,7 +1618,7 @@ int cmd_commit(int argc, const char **argv, const char 
*prefix)
   !current_head
   ? NULL
   : current_head-object.sha1,
-  0);
+  0, NULL);
 
nl = strchr(sb.buf, '\n');
if (nl)
diff --git a/builtin/fetch.c b/builtin/fetch.c
index d784b2e..28e4025 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -246,7 +246,8 @@ static int s_update_ref(const char *action,
rla = default_rla.buf;
snprintf(msg, sizeof(msg), %s: %s, rla, action);
lock = lock_any_ref_for_update(ref-name,
-  check_old ? ref-old_sha1 : NULL, 0);
+  check_old ? ref-old_sha1 : NULL,
+  0, NULL);
if (!lock)
return errno == ENOTDIR ? STORE_REF_ERROR_DF_CONFLICT :
  STORE_REF_ERROR_OTHER;
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index e3eb5fc..a323070 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -524,7 +524,8 @@ static const char *update(struct command *cmd)
return NULL; /* good */
}
else {
-   lock = lock_any_ref_for_update(namespaced_name, old_sha1, 0);
+   lock = lock_any_ref_for_update(namespaced_name, old_sha1,
+  0, NULL);
if (!lock) {
rp_error(failed to lock %s, name);
return failed to lock;
diff --git a/builtin/reflog.c b/builtin/reflog.c
index 54184b3..28d756a 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -366,7 +366,7 @@ static int expire_reflog(const char *ref, const unsigned 
char *sha1, int unused,
 * we take the lock for the ref itself to prevent it from
 * getting updated.
 */
-   lock = lock_any_ref_for_update(ref, sha1, 0);
+   lock = lock_any_ref_for_update(ref, sha1, 0, NULL);
if (!lock)
return error(cannot lock ref '%s', ref);
log_file = git_pathdup(logs/%s, ref);
diff --git a/builtin/replace.c b/builtin/replace.c
index 59d3115..1ecae8d 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -105,7 +105,7 @@ static int replace_object(const char *object_ref, const 
char *replace_ref,
else if (!force)
die(replace ref '%s' already exists, ref);
 
-   lock = lock_any_ref_for_update(ref, prev, 0);
+   lock = lock_any_ref_for_update(ref, prev, 0, NULL);
if (!lock)
die(%s: cannot lock the ref, ref);
if (write_ref_sha1(lock, repl, NULL)  0)
diff --git a/builtin/tag.c b/builtin/tag.c
index af3af3f..2c867d2 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -577,7 +577,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
if (annotate)
create_tag(object, tag, buf, opt, prev, object);
 
-   lock = lock_any_ref_for_update(ref.buf, prev, 0);
+   lock = lock_any_ref_for_update(ref.buf, prev, 0, NULL);
if (!lock)
die(_(%s: cannot lock the ref), ref.buf);
if (write_ref_sha1(lock, object, NULL)  0)
diff --git a/fast-import.c b/fast-import.c
index 23f625f..5c329f6 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -1678,7 +1678,7 @@ static int update_branch(struct branch *b)
return 0;
if (read_ref(b-name, old_sha1))
hashclr(old_sha1);
-   lock = lock_any_ref_for_update(b-name, old_sha1, 0);
+   lock = lock_any_ref_for_update(b-name, old_sha1, 

[PATCH v2 5/8] refs: add function to repack without multiple refs

2013-08-30 Thread Brad King
Generalize repack_without_ref as repack_without_refs to support a list
of refs and implement the former in terms of the latter.

Signed-off-by: Brad King brad.k...@kitware.com
---
 refs.c |   29 ++---
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/refs.c b/refs.c
index 5dd86ee..3bcd26e 100644
--- a/refs.c
+++ b/refs.c
@@ -2414,25 +2414,35 @@ static int curate_packed_ref_fn(struct ref_entry 
*entry, void *cb_data)
return 0;
 }
 
-static int repack_without_ref(const char *refname)
+static int repack_without_refs(const char **refnames, int n)
 {
struct ref_dir *packed;
struct string_list refs_to_delete = STRING_LIST_INIT_DUP;
struct string_list_item *ref_to_delete;
+   int i, removed = 0;
+
+   /* Look for a packed ref: */
+   for (i = 0; i  n; ++i)
+   if (get_packed_ref(refnames[i]))
+   break;
 
-   if (!get_packed_ref(refname))
-   return 0; /* refname does not exist in packed refs */
+   /* Avoid locking if we have nothing to do: */
+   if (i == n)
+   return 0; /* no refname exists in packed refs */
 
if (lock_packed_refs(0)) {
unable_to_lock_error(git_path(packed-refs), errno);
-   return error(cannot delete '%s' from packed refs, refname);
+   return error(cannot delete '%s' from packed refs, 
refnames[i]);
}
packed = get_packed_refs(ref_cache);
 
-   /* Remove refname from the cache: */
-   if (remove_entry(packed, refname) == -1) {
+   /* Remove refnames from the cache: */
+   for (i = 0; i  n; ++i)
+   if (remove_entry(packed, refnames[i]) != -1)
+   removed = 1;
+   if (!removed) {
/*
-* The packed entry disappeared while we were
+* All packed entries disappeared while we were
 * acquiring the lock.
 */
rollback_packed_refs();
@@ -2450,6 +2460,11 @@ static int repack_without_ref(const char *refname)
return commit_packed_refs();
 }
 
+static int repack_without_ref(const char *refname)
+{
+   return repack_without_refs(refname, 1);
+}
+
 static int delete_ref_loose(struct ref_lock *lock, int flag)
 {
int err, i, ret = 0;
-- 
1.7.10.4

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


[PATCH v2 6/8] refs: add update_refs for multiple simultaneous updates

2013-08-30 Thread Brad King
Add 'struct ref_update' to encode the information needed to update or
delete a ref (name, new sha1, optional old sha1, no-deref flag).  Add
function 'update_refs' accepting an array of updates to perform.  First
sort the input array to order locks consistently everywhere and reject
multiple updates to the same ref.  Then acquire locks on all refs with
verified old values.  Then update or delete all refs accordingly.  Fail
if any one lock cannot be obtained or any one old value does not match.

Though the refs themeselves cannot be modified together in a single
atomic transaction, this function does enable some useful semantics.
For example, a caller may create a new branch starting from the head of
another branch and rewind the original branch at the same time.  This
transfers ownership of commits between branches without risk of losing
commits added to the original branch by a concurrent process, or risk of
a concurrent process creating the new branch first.

Signed-off-by: Brad King brad.k...@kitware.com
---
 refs.c |  121 
 refs.h |   14 
 2 files changed, 135 insertions(+)

diff --git a/refs.c b/refs.c
index 3bcd26e..901a38a 100644
--- a/refs.c
+++ b/refs.c
@@ -3238,6 +3238,127 @@ int update_ref(const char *action, const char *refname,
return update_ref_write(action, refname, sha1, lock, onerr);
 }
 
+static int ref_update_compare(const void *r1, const void *r2)
+{
+   struct ref_update *u1 = (struct ref_update *)(r1);
+   struct ref_update *u2 = (struct ref_update *)(r2);
+   int ret;
+   ret = strcmp(u1-ref_name, u2-ref_name);
+   if (ret)
+   return ret;
+   ret = hashcmp(u1-new_sha1, u2-new_sha1);
+   if (ret)
+   return ret;
+   ret = hashcmp(u1-old_sha1, u2-old_sha1);
+   if (ret)
+   return ret;
+   ret = u1-flags - u2-flags;
+   if (ret)
+   return ret;
+   return u1-have_old - u2-have_old;
+}
+
+static int ref_update_reject_duplicates(struct ref_update *updates, int n,
+   enum action_on_err onerr)
+{
+   int i;
+   for (i = 1; i  n; ++i)
+   if (!strcmp(updates[i - 1].ref_name, updates[i].ref_name))
+   break;
+   if (i  n) {
+   const char *str = Multiple updates for ref '%s' not allowed.;
+   switch (onerr) {
+   case MSG_ON_ERR: error(str, updates[i].ref_name); break;
+   case DIE_ON_ERR: die(str, updates[i].ref_name); break;
+   case QUIET_ON_ERR: break;
+   }
+   return 1;
+   }
+   return 0;
+}
+
+int update_refs(const char *action, const struct ref_update *updates_orig,
+   int n, enum action_on_err onerr)
+{
+   int ret = 0, delnum = 0, i;
+   struct ref_update *updates;
+   int *types;
+   struct ref_lock **locks;
+   const char **delnames;
+
+   if (!updates_orig || !n)
+   return 0;
+
+   /* Allocate work space: */
+   updates = xmalloc(sizeof(struct ref_update) * n);
+   types = xmalloc(sizeof(int) * n);
+   locks = xmalloc(sizeof(struct ref_lock *) * n);
+   delnames = xmalloc(sizeof(const char *) * n);
+
+   /* Copy, sort, and reject duplicate refs: */
+   memcpy(updates, updates_orig, sizeof(struct ref_update) * n);
+   qsort(updates, n, sizeof(struct ref_update), ref_update_compare);
+   if (ref_update_reject_duplicates(updates, n, onerr)) {
+   free(updates);
+   free(types);
+   free(locks);
+   free(delnames);
+   return 1;
+   }
+
+   /* Acquire all locks while verifying old values: */
+   for (i = 0; i  n; ++i) {
+   locks[i] = update_ref_lock(updates[i].ref_name,
+  (updates[i].have_old ?
+   updates[i].old_sha1 : NULL),
+  updates[i].flags,
+  types[i], onerr);
+   if (!locks[i])
+   break;
+   }
+
+   /* Abort if we did not get all locks: */
+   if (i  n) {
+   while (--i = 0)
+   unlock_ref(locks[i]);
+   free(updates);
+   free(types);
+   free(locks);
+   free(delnames);
+   return 1;
+   }
+
+   /* Perform updates first so live commits remain referenced: */
+   for (i = 0; i  n; ++i)
+   if (!is_null_sha1(updates[i].new_sha1)) {
+   ret |= update_ref_write(action,
+   updates[i].ref_name,
+   updates[i].new_sha1,
+   locks[i], onerr);
+   locks[i] = 0; /* freed by 

[PATCH v2 7/8] update-ref: support multiple simultaneous updates

2013-08-30 Thread Brad King
Add a --stdin signature to read update instructions from standard input
and apply multiple ref updates together.  Use an input format that
supports any update that could be specified via the command-line,
including object names like 'branch:path with space'.

Signed-off-by: Brad King brad.k...@kitware.com
---
 Documentation/git-update-ref.txt |   21 ++-
 builtin/update-ref.c |  121 +-
 2 files changed, 140 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-update-ref.txt b/Documentation/git-update-ref.txt
index 0df13ff..295d0bb 100644
--- a/Documentation/git-update-ref.txt
+++ b/Documentation/git-update-ref.txt
@@ -8,7 +8,7 @@ git-update-ref - Update the object name stored in a ref safely
 SYNOPSIS
 
 [verse]
-'git update-ref' [-m reason] (-d ref [oldvalue] | [--no-deref] ref 
newvalue [oldvalue])
+'git update-ref' [-m reason] (-d ref [oldvalue] | [--no-deref] ref 
newvalue [oldvalue] | --stdin)
 
 DESCRIPTION
 ---
@@ -58,6 +58,25 @@ archive by creating a symlink tree).
 With `-d` flag, it deletes the named ref after verifying it
 still contains oldvalue.
 
+With `--stdin`, update-ref reads instructions from standard input and
+performs all modifications together.  Empty lines are ignored.
+Each non-empty line is parsed as whitespace-separated arguments.
+Use single-quotes to enclose whitespace and backslashes and an
+unquoted backslash to escape a single quote.  Specify updates with
+lines of the form:
+
+   [--no-deref] [--] ref newvalue [oldvalue]
+
+Lines of any other format or a repeated ref produce an error.
+Specify a zero newvalue to delete a ref and/or a zero oldvalue
+to make sure that a ref not exist.  Use either 40 0 or the
+empty string (written as '') to specify a zero value.
+
+If all refs can be locked with matching oldvalues
+simultaneously all modifications are performed.  Otherwise, no
+modifications are performed.  Note that while each individual
+ref is updated or deleted atomically, a concurrent reader may
+still see a subset of the modifications.
 
 Logging Updates
 ---
diff --git a/builtin/update-ref.c b/builtin/update-ref.c
index 51d2684..eb8db85 100644
--- a/builtin/update-ref.c
+++ b/builtin/update-ref.c
@@ -6,19 +6,129 @@
 static const char * const git_update_ref_usage[] = {
N_(git update-ref [options] -d refname [oldval]),
N_(git update-ref [options]refname newval [oldval]),
+   N_(git update-ref [options] --stdin),
NULL
 };
 
+static const char blank[] =  \t\r\n;
+
+static int updates_size;
+static int updates_count;
+static struct ref_update *updates;
+
+static const char* update_refs_stdin_next_arg(const char* next,
+ struct strbuf *arg)
+{
+   /* Skip leading whitespace: */
+   while (isspace(*next))
+   ++next;
+
+   /* Return NULL when no argument is found: */
+   if (!*next)
+   return NULL;
+
+   /* Parse the argument: */
+   strbuf_reset(arg);
+   for (;;) {
+   char c = *next;
+   if (!c || isspace(c))
+   break;
+   ++next;
+   if (c == '\'') {
+   size_t len = strcspn(next, ');
+   if (!next[len])
+   die(unterminated single-quote: '%s, next);
+   strbuf_add(arg, next, len);
+   next += len + 1;
+   continue;
+   }
+   if (c == '\\') {
+   if (*next == '\'')
+   c = *next++;
+   else
+   die(unquoted backslash not escaping 
+   single-quote: \\%s, next);
+   }
+   strbuf_addch(arg, c);
+   }
+   return next;
+}
+
+static void update_refs_stdin(const char *line)
+{
+   int options = 1, flags = 0, argc = 0;
+   char *argv[3] = {0, 0, 0};
+   struct strbuf arg = STRBUF_INIT;
+   struct ref_update *update;
+   const char *next = line;
+
+   /* Skip blank lines: */
+   if (!line[0])
+   return;
+
+   /* Parse arguments on this line: */
+   while ((next = update_refs_stdin_next_arg(next, arg)) != NULL) {
+   if (options  arg.buf[0] == '-')
+   if (!strcmp(arg.buf, --no-deref))
+   flags |= REF_NODEREF;
+   else if (!strcmp(arg.buf, --))
+   options = 0;
+   else
+   die(unknown option %s, arg.buf);
+   else if (argc = 3)
+   die(too many arguments on line: %s, line);
+   else {
+   argv[argc++] = xstrdup(arg.buf);
+   options = 0;
+   }
+   }
+   strbuf_release(arg);
+
+   

Re: [PATCH] gitweb: Fix the author initials in blame for non-ASCII names

2013-08-30 Thread Simon Ruderich
On Fri, Aug 30, 2013 at 11:13:19AM -0700, Junio C Hamano wrote:
 I think in this function the filehandle is called $fd, not $fh.  Has
 any of you really tested this???

I did, but I applied the change by hand without applying the
patch directly and didn't notice the difference. Sorry for that.

Regards
Simon
-- 
+ privacy is necessary
+ using gnupg http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9
--
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] revision: add --except option

2013-08-30 Thread Felipe Contreras
On Fri, Aug 30, 2013 at 11:48 AM, Junio C Hamano gits...@pobox.com wrote:

 Which means that the approach taken by the patch to only allow
 exclusion of negative ones makes the idea only 50% useful compared
 to its potential.  And I suspect that we can start from 50% which
 is better than 0% and later fill the other 50% would not work in
 this case, without ripping out the SKIP on object approach and
 redoing the --except support from scratch, because SKIP on
 object fundamentally cannot undo the effects of the negative ones,
 because it records the information at a wrong level.

I think it is not 50%, it is 98%. I think one or two persons might use
this secondary feature if ever, and I think waiting for that
implementation will delay the feature that 98% of people would use,
and maybe block it entirely.

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


Re: Officially start moving to the term 'staging area'

2013-08-30 Thread Felipe Contreras
On Thu, Aug 29, 2013 at 2:57 PM, Felipe Contreras
felipe.contre...@gmail.com wrote:

 Again, *everyone* has agreed that index needs to be renamed, and
 staging area is the best option.

 Do I really need to go through all the discussions and list each and
 every person that participated in them, and show to you how everyone
 agreed? Can't you just go and read them again? There was a single
 person that didn't like the term staging area, but he accepted that
 index is definitely not the right term (Drew Northup).

 Here are the threads once again:

 http://thread.gmane.org/gmane.comp.version-control.git/197111
 http://thread.gmane.org/gmane.comp.version-control.git/166675
 http://thread.gmane.org/gmane.comp.version-control.git/115666

I take it you still haven't read those threads, and you don't plan to.
So I have to go through each and every comment and summarize what each
person concluded.

Hopefully you would come back to me before I waste my time, but it
seems there's no other way to make you see the reality of what was
actually already discussed and agreed.

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


[PATCHv2] has_sha1_file: re-check pack directory before giving up

2013-08-30 Thread Jeff King
On Fri, Aug 30, 2013 at 12:28:01AM -0400, Jeff King wrote:

 On Thu, Aug 29, 2013 at 09:10:52PM -0400, Jeff King wrote:
 
  In the case of git-fsck, which uses the
  DO_FOR_EACH_INCLUDE_BROKEN flag, this will cause us to
  erroneously complain that the ref points to an invalid
  object. But for git-repack, which does not use that flag, we
  will skip the ref completely!
 
 Hmm. This is slightly inaccurate. fsck does not use INCLUDE_BROKEN, and
 that is why it recognizes (and prints the warning) the broken ref.
 pack-objects would also print a warning, but would dutifully ignore the
 broken ref during the repack.
 
 So it is actually something like for-each-ref, which _does_ use
 INCLUDE_BROKEN, that behaves differently. And it tends to work, because
 it ends up calling read_sha1_file to find out about the file rather than
 checking has_sha1_file.

Here's a re-roll with a commit message that clarifies the role of
DO_FOR_EACH_INCLUDE_BROKEN. The code is the same, and the diff between
the commit messages is below.

@@ -34,18 +34,17 @@
 ref is broken. If has_sha1_file returns the wrong answer, we
 erroneously will think that the ref is broken.
 
-In the case of git-fsck, which uses the
-DO_FOR_EACH_INCLUDE_BROKEN flag, this will cause us to
-erroneously complain that the ref points to an invalid
-object. But for git-repack, which does not use that flag, we
-will skip the ref completely! So not only will we fail to
-process the new objects that the ref points to (which is
-acceptabale, since the processes are running simultaneously,
-and we might well do our whole repack before the other
-process updates the ref), but we will not see the ref at
-all. Its old objects may be omitted from the pack (and even
-lost, if --unpack-unreachable is used with an expiration
-time).
+For a normal iteration without DO_FOR_EACH_INCLUDE_BROKEN,
+this means that the caller does not see the ref at all
+(neither the old nor the new value).  So not only will we
+fail to see the new value of the ref (which is acceptable,
+since we are running simultaneously with the writer, and we
+might well read the ref before the writer commits its
+write), but we will not see the old value either. For
+programs that act on reachability like pack-objects or
+prune, this can cause data loss, as we may see the objects
+referenced by the original ref value as dangling (and either
+omit them from the pack, or delete them via prune).
 
 There's no test included here, because the success case is
 two processes running simultaneously forever. But you can
@@ -79,7 +78,11 @@
   # fsck.sh
   # now run this simultaneously in another terminal; it
   # repeatedly fscks, looking for us to consider the
-  # newly-pushed ref broken.
+  # newly-pushed ref broken. We cannot use for-each-ref
+  # here, as it uses DO_FOR_EACH_INCLUDE_BROKEN, which
+  # skips the has_sha1_file check (and if it wants
+  # more information on the object, it will actually read
+  # the object, which does the proper two-step lookup)
   cd parent 
   while true; do
 broken=`git fsck 21 | grep remotes/child`

-- 8 --
Subject: has_sha1_file: re-check pack directory before giving up

When we read a sha1 file, we first look for a packed
version, then a loose version, and then re-check the pack
directory again before concluding that we cannot find it.
This lets us handle a process that is writing to the
repository simultaneously (e.g., receive-pack writing a new
pack followed by a ref update, or git-repack packing
existing loose objects into a new pack).

However, we do not do the same trick with has_sha1_file; we
only check the packed objects once, followed by loose
objects. This means that we might incorrectly report that we
do not have an object, even though we could find it if we
simply re-checked the pack directory.

By itself, this is usually not a big deal. The other process
is running simultaneously, so we may run has_sha1_file
before it writes, anyway. It is a race whether we see the
object or not.  However, we may also see other things
the writing process has done (like updating refs); and in
that case, we must be able to also see the new objects.

For example, imagine we are doing a for_each_ref iteration,
and somebody simultaneously pushes. Receive-pack may write
the pack and update a ref after we have examined the
objects/pack directory, but before the iteration gets to the
updated ref. When we do finally see the updated ref,
for_each_ref will call has_sha1_file to check 

Re: [PATCH v3 3/4] get rid of git submodule summary --for-status

2013-08-30 Thread Jens Lehmann
Am 30.08.2013 21:51, schrieb Jens Lehmann:
 Am 30.08.2013 21:40, schrieb Jens Lehmann:
 Am 29.08.2013 23:23, schrieb Matthieu Moy:
 Jens Lehmann jens.lehm...@web.de writes:

 Am 29.08.2013 15:05, schrieb Matthieu Moy:
 The --for-status option was an undocumented option used only by
 wt-status.c, which inserted a header and commented out the output. We can
 achieve the same result within wt-status.c, without polluting the
 submodule command-line options.

 This will make it easier to disable the comments from wt-status.c later.

 Cool, thanks for implementing this!

 But unfortunately this change collides with bc/submodule-status-ignored
 (I added Brian to the CC) which is currently on its way to next.

 Thanks for pointing that out. The patch looks buggy:

 Ok, I'll tak
 
 Sorry, I accidentally hit Send ... :-(
 
 Ok, I'll take a look and will comment on that soon.
 
 --- a/git-submodule.sh
 +++ b/git-submodule.sh
 @@ -1036,6 +1036,13 @@ cmd_summary() {
 do
 # Always show modules deleted or type-changed 
 (blob-module)
 test $status = D -o $status = T  echo $sm_path 
  continue
 +   # Respect the ignore setting for --for-status.
 +   if test -n $for_status
 +   then
 +   name=$(module_name $sm_path)
 +   ignore_config=$(get_submodule_config 
 $name ignore none)
 +   test $status != A -a $ignore_config = all 
  continue
 +   fi

 Because of the missing quotes around $for_status, it seems the test is
 unconditionnaly true:

 $ test -n t ; echo $?
 0
 $ test -n   ; echo $?
 0

Right you are, I did not notice the missing  in my review. Looks like
we also should add one or more tests making sure that submodule summary
and status never honor the ignore settings.
--
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 v3 3/4] get rid of git submodule summary --for-status

2013-08-30 Thread Jens Lehmann
Am 30.08.2013 21:40, schrieb Jens Lehmann:
 Am 29.08.2013 23:23, schrieb Matthieu Moy:
 Jens Lehmann jens.lehm...@web.de writes:

 Am 29.08.2013 15:05, schrieb Matthieu Moy:
 The --for-status option was an undocumented option used only by
 wt-status.c, which inserted a header and commented out the output. We can
 achieve the same result within wt-status.c, without polluting the
 submodule command-line options.

 This will make it easier to disable the comments from wt-status.c later.

 Cool, thanks for implementing this!

 But unfortunately this change collides with bc/submodule-status-ignored
 (I added Brian to the CC) which is currently on its way to next.

 Thanks for pointing that out. The patch looks buggy:
 
 Ok, I'll tak

Sorry, I accidentally hit Send ... :-(

Ok, I'll take a look and will comment on that soon.

 --- a/git-submodule.sh
 +++ b/git-submodule.sh
 @@ -1036,6 +1036,13 @@ cmd_summary() {
 do
 # Always show modules deleted or type-changed 
 (blob-module)
 test $status = D -o $status = T  echo $sm_path 
  continue
 +   # Respect the ignore setting for --for-status.
 +   if test -n $for_status
 +   then
 +   name=$(module_name $sm_path)
 +   ignore_config=$(get_submodule_config $name 
 ignore none)
 +   test $status != A -a $ignore_config = all  
 continue
 +   fi

 Because of the missing quotes around $for_status, it seems the test is
 unconditionnaly true:

 $ test -n t ; echo $?
 0
 $ test -n   ; echo $?
 0

 This makes me wonder why the ignore configuration should be considered
 only with --for-status. Why not turn that into

Please don't. That changes the default behavior of submodule summary,
which never ignores any submodules. The ignore logic was added to core
git after commands like diff and status learned to check submodules for
modifications too. That was bad for people who used submodules to store
many and/or huge files in a way that wouldn't slow down diff or status,
as it slowed them down again. The ignore option allowed them to continue
using submodules for that purpose. They still need to have the submodule
script ignore the ignore settings, because running them is the point in
time they want to take the extra effort to look into those submodules
they normally ignore. And that's why the submodule totally lacks any
option to control the ignore behavior, which we would also have to add
if we would follow your proposal.

So I think it's either changing the default behavior of --for-status or
adding another option (--for-status-wo-comment or such) which will honor
the ignore setting only when called from status.

 --- a/git-submodule.sh
 +++ b/git-submodule.sh
 @@ -1036,6 +1036,13 @@ cmd_summary() {
 do
 # Always show modules deleted or type-changed 
 (blob-module)
 test $status = D -o $status = T  echo $sm_path 
  continue
 +# Respect the ignore setting
 +name=$(module_name $sm_path)
 +ignore_config=$(get_submodule_config $name ignore 
 none)
 +test $status != A -a $ignore_config = all  continue

 ?

 

--
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 v3 3/4] get rid of git submodule summary --for-status

2013-08-30 Thread Jens Lehmann
Am 29.08.2013 23:23, schrieb Matthieu Moy:
 Jens Lehmann jens.lehm...@web.de writes:
 
 Am 29.08.2013 15:05, schrieb Matthieu Moy:
 The --for-status option was an undocumented option used only by
 wt-status.c, which inserted a header and commented out the output. We can
 achieve the same result within wt-status.c, without polluting the
 submodule command-line options.

 This will make it easier to disable the comments from wt-status.c later.

 Cool, thanks for implementing this!

 But unfortunately this change collides with bc/submodule-status-ignored
 (I added Brian to the CC) which is currently on its way to next.
 
 Thanks for pointing that out. The patch looks buggy:

Ok, I'll tak

 --- a/git-submodule.sh
 +++ b/git-submodule.sh
 @@ -1036,6 +1036,13 @@ cmd_summary() {
 do
 # Always show modules deleted or type-changed 
 (blob-module)
 test $status = D -o $status = T  echo $sm_path  
 continue
 +   # Respect the ignore setting for --for-status.
 +   if test -n $for_status
 +   then
 +   name=$(module_name $sm_path)
 +   ignore_config=$(get_submodule_config $name 
 ignore none)
 +   test $status != A -a $ignore_config = all  
 continue
 +   fi
 
 Because of the missing quotes around $for_status, it seems the test is
 unconditionnaly true:
 
 $ test -n t ; echo $?
 0
 $ test -n   ; echo $?
 0
 
 This makes me wonder why the ignore configuration should be considered
 only with --for-status. Why not turn that into
 
 --- a/git-submodule.sh
 +++ b/git-submodule.sh
 @@ -1036,6 +1036,13 @@ cmd_summary() {
 do
 # Always show modules deleted or type-changed 
 (blob-module)
 test $status = D -o $status = T  echo $sm_path  
 continue
 + # Respect the ignore setting
 + name=$(module_name $sm_path)
 + ignore_config=$(get_submodule_config $name ignore 
 none)
 + test $status != A -a $ignore_config = all  continue
 
 ?
 

--
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: What's cooking in git.git (Aug 2013, #07; Wed, 28)

2013-08-30 Thread Jens Lehmann
Am 29.08.2013 01:24, schrieb Junio C Hamano:
 * bc/submodule-status-ignored (2013-08-20) 2 commits
  - submodule: don't print status output with ignore=all
  - submodule: fix confusing variable name
 
  Originally merged to 'next' on 2013-08-22
 
  Will merge to 'next'.

Looks like you didn't merge it to next yet, please don't until we
sorted out the quoting issue Matthieu just brought up.
--
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: Officially start moving to the term 'staging area'

2013-08-30 Thread Felipe Contreras
On Thu, Aug 29, 2013 at 2:57 PM, Felipe Contreras
felipe.contre...@gmail.com wrote:
 On Thu, Aug 29, 2013 at 1:37 PM, Junio C Hamano gits...@pobox.com wrote:

 IIRC, when this was discussed, many non-native speakers had trouble
 with the verb to stage, not just from i18n/l10n point of view.

 Well, you recall incorrectly.

 There was *A SINGLE* non-native speaker that complained, about
 stage, not staging area, Ævar Arnfjörð Bjarmason, and he even said
 he had already translated index/cache to the commit area[1].

Actually, not only did Ævar not have a problem with staging area,
but he told you this argument about i18n/l10n didn't make sense at
all, and you agreed:

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

In fact, all non-native speakers said they liked the term staging
area, like everybody else.

So please enlighten us, which non-native speakers had a problem from
the translation point of view, and why does it matter?

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


Re: Officially start moving to the term 'staging area'

2013-08-30 Thread Felipe Contreras
On Fri, Aug 30, 2013 at 2:11 PM, Felipe Contreras
felipe.contre...@gmail.com wrote:
 On Thu, Aug 29, 2013 at 2:57 PM, Felipe Contreras
 felipe.contre...@gmail.com wrote:

 Here are the threads once again:

 http://thread.gmane.org/gmane.comp.version-control.git/197111
 http://thread.gmane.org/gmane.comp.version-control.git/166675
 http://thread.gmane.org/gmane.comp.version-control.git/115666

 I take it you still haven't read those threads, and you don't plan to.
 So I have to go through each and every comment and summarize what each
 person concluded.

 Hopefully you would come back to me before I waste my time, but it
 seems there's no other way to make you see the reality of what was
 actually already discussed and agreed.

So here's the summary, as I said, *everybody* is in favor of staging
area or something other than index, with the exception of Drew
Northup, I've put a summary of the conclusion of each person that
voiced an opinion on the matter, and I've CC'ed them here, so they can
reiterate their opinion, or clarify it.

Junio, do you accept that virtually *everyone* is in favor of staging
area now?

== Against ==

Drew Northup:
index is good

== For ==

Jay Soffian:
staging area is better

Pete Harlan:
Aghiles:
staging area is good for teaching

Piotr Krukowiecki:
staging area makes sense

Jonathan Nieder:
staging area is better than index

Jeff King:
staging area makes perfect sense

Miles Bader:
staging area is good

Phil Hord:
staging area is better than index/cache

Victor Engmark:
maybe git bucket

David (bouncingcats):
maybe precommit

Alexey Feldgendler:
staging area translates better into Russian (than precommit)

Alexei Sholik:
staging area is better

Zbigniew Jędrzejewski-Szmek:
staging area is better

Ævar Arnfjörð Bjarmason:
In Icelandic index/stage is translated to the commit area

Sebastien Douche:
stage is better than cache/index

Thiago Farina:
precommit is better

Mark Lodato:
staging is the most appropriate

Philip Oakley:
staging area is OK

Matthieu Moy:
something needs to be done

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


Re: Officially start moving to the term 'staging area'

2013-08-30 Thread Felipe Contreras
On Fri, Aug 30, 2013 at 3:40 PM, Felipe Contreras
felipe.contre...@gmail.com wrote:
 On Fri, Aug 30, 2013 at 2:11 PM, Felipe Contreras
 felipe.contre...@gmail.com wrote:
 On Thu, Aug 29, 2013 at 2:57 PM, Felipe Contreras
 felipe.contre...@gmail.com wrote:

 Here are the threads once again:

 http://thread.gmane.org/gmane.comp.version-control.git/197111
 http://thread.gmane.org/gmane.comp.version-control.git/166675
 http://thread.gmane.org/gmane.comp.version-control.git/115666

 I take it you still haven't read those threads, and you don't plan to.
 So I have to go through each and every comment and summarize what each
 person concluded.

 Hopefully you would come back to me before I waste my time, but it
 seems there's no other way to make you see the reality of what was
 actually already discussed and agreed.

 So here's the summary, as I said, *everybody* is in favor of staging
 area or something other than index, with the exception of Drew
 Northup, I've put a summary of the conclusion of each person that
 voiced an opinion on the matter, and I've CC'ed them here, so they can
 reiterate their opinion, or clarify it.

 Junio, do you accept that virtually *everyone* is in favor of staging
 area now?

To avoid bonces, please remove  victor.engm...@terreactive.ch and
alex...@opera.com from the CC list.

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


Re: [PATCH] gitweb: Fix the author initials in blame for non-ASCII names

2013-08-30 Thread Kyle J. McKay

On Aug 30, 2013, at 11:13, Junio C Hamano wrote:

Junio C Hamano gits...@pobox.com writes:


Ævar Arnfjörð Bjarmason  ava...@gmail.com writes:


Acked-by: Jakub Narębski jna...@gmail.com
Tested-by: Ævar Arnfjörð Bjarmason ava...@gmail.com
Tested-by: Simon Ruderich si...@ruderich.org
---
+++ b/gitweb/gitweb.perl
@@ -6631,6 +6631,7 @@ sub git_blame_common {
...
+   binmode $fh, ':utf8';




[Fri Aug 30 17:48:17 2013] gitweb.perl: Global symbol $fh requires
explicit package name at /home/gitster/w/buildfarm/next/t/../gitweb/ 
gitweb.perl line 6634.
[Fri Aug 30 17:48:17 2013] gitweb.perl: Execution of /home/gitster/ 
w/buildfarm/next/t/../gitweb/gitweb.perl aborted due to compilation  
errors.


I think in this function the filehandle is called $fd, not $fh.  Has
any of you really tested this???


What happens if the author name is written in ISO-8859-1 instead of  
UTF-8 in the actual commit object itself?


I'm pretty sure I've seen this where older commits have a ISO-8859-1  
author name and then newer commits have a UTF-8 version of the same  
author's name.


In fact, in the git repository itself, look at commit 0cb3f80d (UTF-8)  
and commit 7eb93c89 (ISO-8859-1) to see this in action.--

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

2013-08-30 Thread Felipe Contreras
There's no need to remove 'refs/heads/' yet again.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 git-pull.sh | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/git-pull.sh b/git-pull.sh
index f0df41c..3bdcbfd 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -166,7 +166,6 @@ error_on_no_merge_candidates () {
op_prep=with
fi
 
-   curr_branch=${curr_branch#refs/heads/}
upstream=$(git config branch.$curr_branch.merge)
remote=$(git config branch.$curr_branch.remote)
 
@@ -183,7 +182,7 @@ error_on_no_merge_candidates () {
echo You asked to pull from the remote '$1', but did not 
specify
echo a branch. Because this is not the default configured 
remote
echo for your current branch, you must specify a branch on the 
command line.
-   elif [ -z $curr_branch -o -z $upstream ]; then
+   elif [ -z $curr_branch_short -o -z $upstream ]; then
. git-parse-remote
error_on_missing_default_upstream pull $op_type $op_prep \
git pull remote branch
-- 
1.8.4-fc

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


[PATCH 0/6] Trivial cleanups and fixes

2013-08-30 Thread Felipe Contreras
Felipe Contreras (6):
  reset: trivial refactoring
  branch: trivial style fix
  rebase: trivial style fixes
  reset: trivial style cleanup
  add: trivial style cleanup
  pull: trivial cleanup

 branch.c|  2 +-
 builtin/add.c   | 10 +-
 builtin/reset.c | 11 ---
 git-pull.sh |  3 +--
 git-rebase.sh   |  4 ++--
 5 files changed, 13 insertions(+), 17 deletions(-)

-- 
1.8.4-fc

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


[PATCH 3/6] rebase: trivial style fixes

2013-08-30 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 git-rebase.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/git-rebase.sh b/git-rebase.sh
index 8d7659a..2c02853 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -324,7 +324,7 @@ done
 test $# -gt 2  usage
 
 if test -n $cmd 
-   test $interactive_rebase != explicit
+   test $interactive_rebase != explicit
 then
die $(gettext The --exec option must be used with the --interactive 
option)
 fi
@@ -486,7 +486,7 @@ case $# in
switch_to=$1
 
if git show-ref --verify --quiet -- refs/heads/$1 
-  orig_head=$(git rev-parse -q --verify refs/heads/$1)
+   orig_head=$(git rev-parse -q --verify refs/heads/$1)
then
head_name=refs/heads/$1
elif orig_head=$(git rev-parse -q --verify $1)
-- 
1.8.4-fc

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


[PATCH 2/6] branch: trivial style fix

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

diff --git a/branch.c b/branch.c
index c5c6984..546c4b4 100644
--- a/branch.c
+++ b/branch.c
@@ -307,7 +307,7 @@ void create_branch(const char *head,
 start_name);
 
if (real_ref  track)
-   setup_tracking(ref.buf+11, real_ref, track, quiet);
+   setup_tracking(ref.buf + 11, real_ref, track, quiet);
 
if (!dont_change_ref)
if (write_ref_sha1(lock, sha1, msg)  0)
-- 
1.8.4-fc

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


[PATCH 4/6] reset: trivial style cleanup

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

diff --git a/builtin/reset.c b/builtin/reset.c
index 225e3f1..7e65934 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -323,7 +323,7 @@ int cmd_reset(int argc, const char **argv, const char 
*prefix)
die_if_unmerged_cache(reset_type);
 
if (reset_type != SOFT) {
-   struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
+   struct lock_file *lock = xcalloc(1, sizeof(*lock));
int newfd = hold_locked_index(lock, 1);
if (reset_type == MIXED) {
int flags = quiet ? REFRESH_QUIET : 
REFRESH_IN_PORCELAIN;
-- 
1.8.4-fc

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


[PATCH 1/6] reset: trivial refactoring

2013-08-30 Thread Felipe Contreras
After commit 3fde386 (reset [--mixed]: use diff-based reset whether or
not pathspec was given), some code can be moved to the 'reset_type ==
MIXED' check.

Let's move the code that is specific to MIXED.

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

diff --git a/builtin/reset.c b/builtin/reset.c
index afa6e02..225e3f1 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -326,8 +326,11 @@ int cmd_reset(int argc, const char **argv, const char 
*prefix)
struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
int newfd = hold_locked_index(lock, 1);
if (reset_type == MIXED) {
+   int flags = quiet ? REFRESH_QUIET : 
REFRESH_IN_PORCELAIN;
if (read_from_tree(pathspec, sha1))
return 1;
+   refresh_index(the_index, flags, NULL, NULL,
+ _(Unstaged changes after reset:));
} else {
int err = reset_index(sha1, reset_type, quiet);
if (reset_type == KEEP  !err)
@@ -336,12 +339,6 @@ int cmd_reset(int argc, const char **argv, const char 
*prefix)
die(_(Could not reset index file to revision 
'%s'.), rev);
}
 
-   if (reset_type == MIXED) { /* Report what has not been updated. 
*/
-   int flags = quiet ? REFRESH_QUIET : 
REFRESH_IN_PORCELAIN;
-   refresh_index(the_index, flags, NULL, NULL,
- _(Unstaged changes after reset:));
-   }
-
if (write_cache(newfd, active_cache, active_nr) ||
commit_locked_index(lock))
die(_(Could not write new index file.));
-- 
1.8.4-fc

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


[PATCH 5/6] add: trivial style cleanup

2013-08-30 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 builtin/add.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/builtin/add.c b/builtin/add.c
index 8266a9c..a1e1e0e 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -336,7 +336,7 @@ static int edit_patch(int argc, const char **argv, const 
char *prefix)
git_config(git_diff_basic_config, NULL); /* no diff UI options */
 
if (read_cache()  0)
-   die (_(Could not read the index));
+   die(_(Could not read the index));
 
init_revisions(rev, prefix);
rev.diffopt.context = 7;
@@ -347,11 +347,11 @@ static int edit_patch(int argc, const char **argv, const 
char *prefix)
DIFF_OPT_SET(rev.diffopt, IGNORE_DIRTY_SUBMODULES);
out = open(file, O_CREAT | O_WRONLY, 0666);
if (out  0)
-   die (_(Could not open '%s' for writing.), file);
+   die(_(Could not open '%s' for writing.), file);
rev.diffopt.file = xfdopen(out, w);
rev.diffopt.close_file = 1;
if (run_diff_files(rev, 0))
-   die (_(Could not write patch));
+   die(_(Could not write patch));
 
launch_editor(file, NULL, NULL);
 
@@ -364,7 +364,7 @@ static int edit_patch(int argc, const char **argv, const 
char *prefix)
child.git_cmd = 1;
child.argv = apply_argv;
if (run_command(child))
-   die (_(Could not apply '%s'), file);
+   die(_(Could not apply '%s'), file);
 
unlink(file);
free(file);
@@ -598,7 +598,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 
unplug_bulk_checkin();
 
- finish:
+finish:
if (active_cache_changed) {
if (write_cache(newfd, active_cache, active_nr) ||
commit_locked_index(lock_file))
-- 
1.8.4-fc

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


Re: [PATCH v2 7/8] update-ref: support multiple simultaneous updates

2013-08-30 Thread Junio C Hamano
Brad King brad.k...@kitware.com writes:

 Add a --stdin signature to read update instructions from standard input
 and apply multiple ref updates together.  Use an input format that
 supports any update that could be specified via the command-line,
 including object names like 'branch:path with space'.

 Signed-off-by: Brad King brad.k...@kitware.com
 ---
  Documentation/git-update-ref.txt |   21 ++-
  builtin/update-ref.c |  121 
 +-
  2 files changed, 140 insertions(+), 2 deletions(-)

 diff --git a/Documentation/git-update-ref.txt 
 b/Documentation/git-update-ref.txt
 index 0df13ff..295d0bb 100644
 --- a/Documentation/git-update-ref.txt
 +++ b/Documentation/git-update-ref.txt
 @@ -8,7 +8,7 @@ git-update-ref - Update the object name stored in a ref safely
  SYNOPSIS
  
  [verse]
 -'git update-ref' [-m reason] (-d ref [oldvalue] | [--no-deref] ref 
 newvalue [oldvalue])
 +'git update-ref' [-m reason] (-d ref [oldvalue] | [--no-deref] ref 
 newvalue [oldvalue] | --stdin)
  
  DESCRIPTION
  ---
 @@ -58,6 +58,25 @@ archive by creating a symlink tree).
  With `-d` flag, it deletes the named ref after verifying it
  still contains oldvalue.
  
 +With `--stdin`, update-ref reads instructions from standard input and
 +performs all modifications together.  Empty lines are ignored.
 +Each non-empty line is parsed as whitespace-separated arguments.
 +Use single-quotes to enclose whitespace and backslashes and an
 +unquoted backslash to escape a single quote.

That is somewhat unusual.

When we need to deal with arbitrary strings (like pathnames), other
parts of the system usually give the user two interfaces, --stdin
with and without -z, and the strings are C-quoted when run without
the -z option, and terminated with NUL when run with the -z option.

 +Specify updates with
 +lines of the form:
 +
 + [--no-deref] [--] ref newvalue [oldvalue]

What is -- doing here?  refs given to update-ref begin with refs/
(otherwise it is HEAD), no?
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] branch: improve verbose option

2013-08-30 Thread Felipe Contreras
Hi,

This has been discussed before:

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

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

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

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

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

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

-- 
1.8.4-fc

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


[PATCH 1/2] branch: trivial cleanup

2013-08-30 Thread Felipe Contreras
No functional changes.

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

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

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


[PATCH 2/2] branch: reorganize verbose options

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

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

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

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


[PATCH] gitk: fix race error at click while reading commits

2013-08-30 Thread Max Kirillov
If I click the commit list while reading (or rereading, by Shift-F5)
commits, sometimes an error message appears:
`can't read pending_select: no such variable',
because pending_select is reset during update.

Just removing update or saving value in local variable would result in
occasional scrolling to some random commit in history, often very far
from the beginning. So nicer choice is skip the selection if change is
detected

Signed-off-by: Max Kirillov m...@max630.net
---
 gitk-git/gitk | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index b3706fc..5a8a57c 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -5038,8 +5038,11 @@ proc layoutmore {} {
 }
 if {[info exists pending_select] 
[commitinview $pending_select $curview]} {
+   set save_pending_select $pending_select
update
-   selectline [rowofcommit $pending_select] 1
+   if {[info exists pending_select]  $pending_select == 
$save_pending_select} {
+   selectline [rowofcommit $save_pending_select] 1
+   }
 }
 drawvisible
 }
-- 
1.8.4.rc3.902.g80a4b9e
--
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] revision: introduce --exclude=glob to tame wildcards

2013-08-30 Thread Junio C Hamano
People often find git log --branches etc. that includes _all_
branches is cumbersome to use when they want to grab most but except
some.  The same applies to --tags, --all and --glob.

Teach the revision machinery to remember patterns, and then upon the
next such a globbing option, exclude those that match the pattern.

With this, I can view only my integration branches (e.g. maint,
master, etc.) without topic branches, which are named after two
letters from primary authors' names, slash and topic name.

git rev-list --no-walk --exclude=??/* --branches |
git name-rev --refs refs/heads/* --stdin

This one shows things reachable from local and remote branches that
have not been merged to the integration branches.

git log --remotes --branches --not --exclude=??/* --branches

It may be a bit rough around the edges, in that the pattern to give
the exclude option depends on what globbing option follows.  In
these examples, the pattern ??/* is used, not refs/heads/??/*,
because the globbing option that follows the --exclude=pattern
is --branches.  As each use of globbing option resets previously
set --exclude, this may not be such a bad thing, though.

Signed-off-by: Junio C Hamano gits...@pobox.com
---

 Junio C Hamano gits...@pobox.com writes:

  It may be a good idea to step back a bit and think of this topic as
  a way to enhance the --branches option and its friends with only the
  inclusive wildcard semantics.  It lets us include those that match
  the pattern with --branches=wip/*, but there is no way to say oh
  by the way, I do not want those that match this pattern included
  when you expand this short-hand.  We have --branches=pattern that
  is inclusive; perhaps it can be prefixed with --branches=!pattern to
  pre-declare whatever the next --branches expands to, do not include
  those that match this pattern, or something, which would make the
  earlier wip example to be:
 
   --all --not --branches='!wip/*' --branches

 So here is a quick attempt at that approach, which does not look
 too intrusive. 

 revision.c | 50 --
 revision.h |  3 +++
 2 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/revision.c b/revision.c
index 84ccc05..3e82874 100644
--- a/revision.c
+++ b/revision.c
@@ -1180,11 +1180,28 @@ struct all_refs_cb {
const char *name_for_errormsg;
 };
 
+static int ref_excluded(struct rev_info *revs, const char *path)
+{
+   struct string_list_item *item;
+
+   if (!revs-ref_excludes)
+   return 0;
+   for_each_string_list_item(item, revs-ref_excludes) {
+   if (!fnmatch(item-string, path, 0))
+   return 1;
+   }
+   return 0;
+}
+
 static int handle_one_ref(const char *path, const unsigned char *sha1, int 
flag, void *cb_data)
 {
struct all_refs_cb *cb = cb_data;
-   struct object *object = get_reference(cb-all_revs, path, sha1,
- cb-all_flags);
+   struct object *object;
+
+   if (ref_excluded(cb-all_revs, path))
+   return 0;
+
+   object = get_reference(cb-all_revs, path, sha1, cb-all_flags);
add_rev_cmdline(cb-all_revs, object, path, REV_CMD_REF, cb-all_flags);
add_pending_sha1(cb-all_revs, path, sha1, cb-all_flags);
return 0;
@@ -1197,6 +1214,24 @@ static void init_all_refs_cb(struct all_refs_cb *cb, 
struct rev_info *revs,
cb-all_flags = flags;
 }
 
+static void clear_ref_exclusion(struct rev_info *revs)
+{
+   if (revs-ref_excludes) {
+   string_list_clear(revs-ref_excludes, 0);
+   free(revs-ref_excludes);
+   }
+   revs-ref_excludes = NULL;
+}
+
+static void add_ref_exclusion(struct rev_info *revs, const char *exclude)
+{
+   if (!revs-ref_excludes) {
+   revs-ref_excludes = xcalloc(1, sizeof(*revs-ref_excludes));
+   revs-ref_excludes-strdup_strings = 1;
+   }
+   string_list_append(revs-ref_excludes, exclude);
+}
+
 static void handle_refs(const char *submodule, struct rev_info *revs, unsigned 
flags,
int (*for_each)(const char *, each_ref_fn, void *))
 {
@@ -1953,33 +1988,44 @@ static int handle_revision_pseudo_opt(const char 
*submodule,
if (!strcmp(arg, --all)) {
handle_refs(submodule, revs, *flags, for_each_ref_submodule);
handle_refs(submodule, revs, *flags, head_ref_submodule);
+   clear_ref_exclusion(revs);
} else if (!strcmp(arg, --branches)) {
handle_refs(submodule, revs, *flags, 
for_each_branch_ref_submodule);
+   clear_ref_exclusion(revs);
} else if (!strcmp(arg, --bisect)) {
handle_refs(submodule, revs, *flags, for_each_bad_bisect_ref);
handle_refs(submodule, revs, *flags ^ (UNINTERESTING | BOTTOM), 
for_each_good_bisect_ref);
revs-bisect = 1;
} else if (!strcmp(arg, --tags)) {
   

Re: [RFC/PATCH v2 3/3] status: introduce status.displayCommentChar to disable display of #

2013-08-30 Thread brian m. carlson
On Wed, Aug 28, 2013 at 04:18:03PM -0400, Jeff King wrote:
 On Wed, Aug 28, 2013 at 01:05:38PM -0700, Junio C Hamano wrote:
 
  What are our plans to help existing scripts people have written over
  time, especially before status -s was invented, that will be
  broken by use of this?
 
 I thought that our response to parsing the long output of git status
 was always you are doing it wrong. The right way has always been to
 run the plumbing tools yourself, followed eventually by the --porcelain
 mode to git status being blessed as a convenient plumbing.
 
 I will not say that people might not do it anyway, but at what point do
 we say you were warned?

It already has changed.  At cPanel, we had code that broke with a new
version of git because the output of git status changed between 1.7.11
and 1.8.3.  We fixed it to use --porcelain and had no problems.

-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187


signature.asc
Description: Digital signature


Re: [PATCH] revision: introduce --exclude=glob to tame wildcards

2013-08-30 Thread Duy Nguyen
On Sat, Aug 31, 2013 at 6:55 AM, Junio C Hamano gits...@pobox.com wrote:
 +static int ref_excluded(struct rev_info *revs, const char *path)
 +{
 +   struct string_list_item *item;
 +
 +   if (!revs-ref_excludes)
 +   return 0;
 +   for_each_string_list_item(item, revs-ref_excludes) {
 +   if (!fnmatch(item-string, path, 0))
 +   return 1;
 +   }
 +   return 0;
 +}

If you pursue this, please use wildmatch instead so it supports foo/**.
-- 
Duy
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] revision: introduce --exclude=glob to tame wildcards

2013-08-30 Thread Junio C Hamano
Duy Nguyen pclo...@gmail.com writes:

 On Sat, Aug 31, 2013 at 6:55 AM, Junio C Hamano gits...@pobox.com wrote:
 +static int ref_excluded(struct rev_info *revs, const char *path)
 +{
 +   struct string_list_item *item;
 +
 +   if (!revs-ref_excludes)
 +   return 0;
 +   for_each_string_list_item(item, revs-ref_excludes) {
 +   if (!fnmatch(item-string, path, 0))
 +   return 1;
 +   }
 +   return 0;
 +}

 If you pursue this, please use wildmatch instead so it supports foo/**.

The thought crossed my mind and I think we should match what the
existing --glob=pattern option does.  A cursory look in
refs.c::filter_refs() used by refs.c::for_each_glob_ref_in() tells
me that we are using fnmatch without FNM_PATHNAME, so that is what
the above part does.
--
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] Make setup_git_env() resolve .git file when $GIT_DIR is not specified

2013-08-30 Thread Nguyễn Thái Ngọc Duy
This makes reinitializing on a .git file repository work.

This is probably the only case that setup_git_env() (via
set_git_dir()) is called on a .git file. Other cases in
setup_git_dir_gently() and enter_repo() both cover .git file case
explicitly because they need to verify the target repo is valid.

Signed-off-by: Junio C Hamano gits...@pobox.com
Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com
Reported-by: Ximin Luo infini...@gmx.com
---
 Slight change in the patch to xstrdup(gitfile) because read_gitfile
 returns a static buffer.

 environment.c   | 9 -
 t/t0001-init.sh | 4 
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/environment.c b/environment.c
index 5398c36..378254c 100644
--- a/environment.c
+++ b/environment.c
@@ -123,14 +123,13 @@ static char *expand_namespace(const char *raw_namespace)
 
 static void setup_git_env(void)
 {
+   const char *gitfile;
+
git_dir = getenv(GIT_DIR_ENVIRONMENT);
-   git_dir = git_dir ? xstrdup(git_dir) : NULL;
-   if (!git_dir) {
-   git_dir = read_gitfile(DEFAULT_GIT_DIR_ENVIRONMENT);
-   git_dir = git_dir ? xstrdup(git_dir) : NULL;
-   }
if (!git_dir)
git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
+   gitfile = read_gitfile(git_dir);
+   git_dir = xstrdup(gitfile ? gitfile : git_dir);
git_object_dir = getenv(DB_ENVIRONMENT);
if (!git_object_dir) {
git_object_dir = xmalloc(strlen(git_dir) + 9);
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index ad66410..9fb582b 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -379,6 +379,10 @@ test_expect_success 'init with separate gitdir' '
test -d realgitdir/refs
 '
 
+test_expect_success 're-init on .git file' '
+   ( cd newdir  git init )
+'
+
 test_expect_success 're-init to update git link' '
(
cd newdir 
-- 
1.8.2.83.gc99314b

--
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] Add testcase for needless objects during a shallow fetch

2013-08-30 Thread Duy Nguyen
On Thu, Aug 29, 2013 at 4:50 PM, Duy Nguyen pclo...@gmail.com wrote:
 On Wed, Aug 28, 2013 at 11:02 PM, Matthijs Kooijman matth...@stdin.nl wrote:
 This is a testcase that checks for a problem where, during a specific
 shallow fetch where the client does not have any commits that are a
 successor of the new shallow root (i.e., the fetch creates a new
 detached piece of history), the server would simply send over _all_
 objects, instead of taking into account the objects already present in
 the client.

 Thanks. This reminds me I should add a test case in the 4/6 to
 demonstrate the regression and let it verify again in 6/6 that the
 temporary regression is gone. Will reroll the series with your patch
 included.

No. It's too hard. The difference is what base a delta object use and
checking that might not be entirely reliable because the algorithm in
pack-objects might change some day.
-- 
Duy
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] remote-hg: skip ill-formed references

2013-08-30 Thread Felipe Contreras
On Fri, Aug 30, 2013 at 8:15 PM, Max Kirillov m...@max630.net wrote:
 References which fail check_refname_format() cause the whole
 import to fail. This might be undesirable if the references
 are not important.

 A better solution would be to provide some mapping, either
 by some reversible encoding, or by generating and storing
 the associations locally.

 But this is already going to allow working with many
 existing repositories.

Which repository triggered this?

Maybe we should do something similar as in git-remote-bzr:


def ref_is_valid(name):
return not True in [c in name for c in '~^: \\']


if not ref_is_valid(tag):
continue
print ? refs/tags/%s % tag

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


[PATCH v2] Document pack v4 format

2013-08-30 Thread Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com
---
 Incorporated suggestions by Nico and Junio. I went ahead and added
 escape hatches for converting thin packs to full ones so the document
 does not really match the code (I've been watching Nico's repository,
 commit reading is added, good stuff!)

 The proposal is, value 0 in the index to ident table is reserved,
 followed by the ident string. The real index to ident table is idx-1.

 Similarly, the value 1 in the index to path name table is reserved 
 (value 0 is already used for referring back to base tree) so the
 actual index is idx-2.

 Documentation/technical/pack-format.txt | 128 +++-
 1 file changed, 127 insertions(+), 1 deletion(-)

diff --git a/Documentation/technical/pack-format.txt 
b/Documentation/technical/pack-format.txt
index 8e5bf60..c866287 100644
--- a/Documentation/technical/pack-format.txt
+++ b/Documentation/technical/pack-format.txt
@@ -1,7 +1,7 @@
 Git pack format
 ===
 
-== pack-*.pack files have the following format:
+== pack-*.pack files version 2 and 3 have the following format:
 
- A header appears at the beginning and consists of the following:
 
@@ -36,6 +36,127 @@ Git pack format
 
   - The trailer records 20-byte SHA-1 checksum of all of the above.
 
+== pack-*.pack files version 4 have the following format:
+
+   - A header appears at the beginning and consists of the following:
+
+ 4-byte signature:
+   The signature is: {'P', 'A', 'C', 'K'}
+
+ 4-byte version number (network byte order): must be 4
+
+ 4-byte number of objects contained in the pack (network byte order)
+
+   - A series of tables, described separately.
+
+   - The tables are followed by number of object entries, each of
+ which looks like below:
+
+ (undeltified representation)
+ n-byte type and length (4-bit type, (n-1)*7+4-bit length)
+ data
+
+ (deltified representation)
+ n-byte type and length (4-bit type, (n-1)*7+4-bit length)
+ base object name in SHA-1 reference encoding
+ compressed delta data
+
+ In undeltified format, blobs and tags ares compressed. Trees are
+ not compressed at all. Some headers in commits are stored
+ uncompressed, the rest is compressed. Tree and commit
+ representations are described in detail separately.
+
+ Blobs and tags are deltified and compressed the same way in
+ v3. Commits are not delitifed. Trees are deltified using
+ undeltified representation.
+
+  - The trailer records 20-byte SHA-1 checksum of all of the above.
+
+=== Pack v4 tables
+
+ - A table of sorted SHA-1 object names for all objects contained in
+   the pack.
+
+   This table can be referred to using SHA-1 reference encoding:
+   It's an index number in variable length encoding. If it's
+   non-zero, its value minus one is the index in this table. If it's
+   zero, 20 bytes of SHA-1 is followed.
+
+ - Ident table: the uncompressed length in variable encoding,
+   followed by zlib-compressed dictionary. Each entry consists of
+   two prefix bytes storing timezone followed by a NUL-terminated
+   string.
+
+   Entries should be sorted by frequency so that the most frequent
+   entry has the smallest index, thus most efficient variable
+   encoding.
+
+   The table can be referred to using ident reference encoding:
+   It's an index number in variable length encoding. If it's
+   non-zero, its value minus one is the index in this table. If it's
+   zero, a new entry in the same format is followed: two prefix
+   bytes and a NUL-terminated string.
+
+ - Tree path table: the same format to ident table. Each entry
+   consists of two prefix bytes storing tree entry mode, then a
+   NUL-terminated path name. Same sort order recommendation applies.
+
+=== Commit representation
+
+  - n-byte type and length (4-bit type, (n-1)*7+4-bit length)
+
+  - Tree SHA-1 in SHA-1 reference encoding
+
+  - Parent count in variable length encoding
+
+  - Parent SHA-1s in SHA-1 reference encoding
+
+  - Author reference in ident reference encoding
+
+  - Author timestamp in variable length encoding
+
+  - Committer reference in ident reference encoding
+
+  - Committer timestamp in variable length encoding
+
+  - Compressed data of remaining header and the body
+
+=== Tree representation
+
+  - n-byte type and length (4-bit type, (n-1)*7+4-bit length)
+
+  - Number of tree entries in variable length encoding
+
+  - A number of entries, each starting with path component reference:
+an number, in variable length encoding.
+
+If the path component reference is greater than 1, its value minus
+two is the index in tree path table. The path component reference
+is followed by the tree entry SHA-1 in SHA-1 reference encoding.
+
+If the path component reference is 1, it's followed by
+
+- two prefix bytes representing tree entry mode
+
+- NUL-terminated path name
+
+- tree entry SHA-1 in SHA-1 reference encoding
+
+If 

Re: [PATCH 2/6] branch: trivial style fix

2013-08-30 Thread Junio C Hamano
Good.  Thanks.

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


Re: [PATCH 5/6] add: trivial style cleanup

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

 Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
 ---
  builtin/add.c | 10 +-
  1 file changed, 5 insertions(+), 5 deletions(-)

 diff --git a/builtin/add.c b/builtin/add.c
 index 8266a9c..a1e1e0e 100644
 --- a/builtin/add.c
 +++ b/builtin/add.c
 @@ -336,7 +336,7 @@ static int edit_patch(int argc, const char **argv, const 
 char *prefix)
   git_config(git_diff_basic_config, NULL); /* no diff UI options */
  
   if (read_cache()  0)
 - die (_(Could not read the index));
 + die(_(Could not read the index));
  
   init_revisions(rev, prefix);
   rev.diffopt.context = 7;
 @@ -347,11 +347,11 @@ static int edit_patch(int argc, const char **argv, 
 const char *prefix)
   DIFF_OPT_SET(rev.diffopt, IGNORE_DIRTY_SUBMODULES);
   out = open(file, O_CREAT | O_WRONLY, 0666);
   if (out  0)
 - die (_(Could not open '%s' for writing.), file);
 + die(_(Could not open '%s' for writing.), file);
   rev.diffopt.file = xfdopen(out, w);
   rev.diffopt.close_file = 1;
   if (run_diff_files(rev, 0))
 - die (_(Could not write patch));
 + die(_(Could not write patch));
  
   launch_editor(file, NULL, NULL);
  
 @@ -364,7 +364,7 @@ static int edit_patch(int argc, const char **argv, const 
 char *prefix)
   child.git_cmd = 1;
   child.argv = apply_argv;
   if (run_command(child))
 - die (_(Could not apply '%s'), file);
 + die(_(Could not apply '%s'), file);
  
   unlink(file);
   free(file);

Good. These often bothered me.
--
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 3/6] rebase: trivial style fixes

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

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

 diff --git a/git-rebase.sh b/git-rebase.sh
 index 8d7659a..2c02853 100755
 --- a/git-rebase.sh
 +++ b/git-rebase.sh
 @@ -324,7 +324,7 @@ done
  test $# -gt 2  usage
  
  if test -n $cmd 
 -   test $interactive_rebase != explicit
 + test $interactive_rebase != explicit
  then
   die $(gettext The --exec option must be used with the --interactive 
 option)
  fi
 @@ -486,7 +486,7 @@ case $# in
   switch_to=$1
  
   if git show-ref --verify --quiet -- refs/heads/$1 
 -orig_head=$(git rev-parse -q --verify refs/heads/$1)
 + orig_head=$(git rev-parse -q --verify refs/heads/$1)
   then
   head_name=refs/heads/$1
   elif orig_head=$(git rev-parse -q --verify $1)

I am not sure about this change.  I do not personally have strong
preference on this, but it would be better to be consistent.

The style of the original we see above seems to be the one that is
consistently used in this file for conditionals that span multiple
lines.  That is, to align the beginning of subsequent lines with the
beginning of the conditional (i.e. the g in git show-ref on the
first line)---which happens to be in line with what we use in our C
sources, too.

I see there is one oddball in that file, though.

 git-rebase.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/git-rebase.sh b/git-rebase.sh
index 8d7659a..187793e 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -422,7 +422,7 @@ then
case $# in
0)
if ! upstream_name=$(git rev-parse --symbolic-full-name \
-   --verify -q @{upstream} 2/dev/null)
+  --verify -q @{upstream} 2/dev/null)
then
. git-parse-remote
error_on_missing_default_upstream rebase rebase \

--
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 4/6] reset: trivial style cleanup

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

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

 diff --git a/builtin/reset.c b/builtin/reset.c
 index 225e3f1..7e65934 100644
 --- a/builtin/reset.c
 +++ b/builtin/reset.c
 @@ -323,7 +323,7 @@ int cmd_reset(int argc, const char **argv, const char 
 *prefix)
   die_if_unmerged_cache(reset_type);
  
   if (reset_type != SOFT) {
 - struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
 + struct lock_file *lock = xcalloc(1, sizeof(*lock));

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


Re: [PATCH 6/6] pull: trivial cleanup

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

 There's no need to remove 'refs/heads/' yet again.

 Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
 ---
  git-pull.sh | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

 diff --git a/git-pull.sh b/git-pull.sh
 index f0df41c..3bdcbfd 100755
 --- a/git-pull.sh
 +++ b/git-pull.sh
 @@ -166,7 +166,6 @@ error_on_no_merge_candidates () {
   op_prep=with
   fi
  
 - curr_branch=${curr_branch#refs/heads/}

The code assumes that at this point $curr_branch has the result of
git symbolic-ref -q HEAD it did at the beginning, before it entered
in the command line parsing loop.  But immediately after it, the
code sets up $curr_branch_short for the value this code computes.

   upstream=$(git config branch.$curr_branch.merge)
   remote=$(git config branch.$curr_branch.remote)

So it appears to me that the above two lines that are not updated
would introduce a regression.  Am I missing something trivial?

Puzzled.


 @@ -183,7 +182,7 @@ error_on_no_merge_candidates () {
   echo You asked to pull from the remote '$1', but did not 
 specify
   echo a branch. Because this is not the default configured 
 remote
   echo for your current branch, you must specify a branch on the 
 command line.
 - elif [ -z $curr_branch -o -z $upstream ]; then
 + elif [ -z $curr_branch_short -o -z $upstream ]; then

If $curr_branch in the original code was (wasn't) an empty string,
then with the updated code that does not strip refs/heads/ from the
beginning of it after applying the first hunk of this patch, the
variable is (isn't) an empty string, respectively. So there is no
need for this hunk, I think.

   . git-parse-remote
   error_on_missing_default_upstream pull $op_type $op_prep \
   git pull remote branch
--
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 0/4] t: branch: fixes and cleanups

2013-08-30 Thread Felipe Contreras
Felipe Contreras (4):
  t: branch: trivial style fix
  t: branch: fix typo
  t: branch: fix broken  chains
  t: branch: improve test rollback

 t/t3200-branch.sh | 82 +++
 1 file changed, 41 insertions(+), 41 deletions(-)

-- 
1.8.4-fc

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


[PATCH 2/4] t: branch: fix typo

2013-08-30 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 t/t3200-branch.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index ea548f9..3134652 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -351,7 +351,7 @@ test_expect_success 'test overriding tracking setup via 
--no-track' '
 test_expect_success 'no tracking without .fetch entries' '
git config branch.autosetupmerge true 
git branch my6 s 
-   git config branch.automsetupmerge false 
+   git config branch.autosetupmerge false 
test -z $(git config branch.my6.remote) 
test -z $(git config branch.my6.merge)
 '
-- 
1.8.4-fc

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


[PATCH 1/4] t: branch: trivial style fix

2013-08-30 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 t/t3200-branch.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 44ec6a4..ea548f9 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -14,7 +14,8 @@ test_expect_success 'prepare a trivial repository' '
echo World A 
git update-index --add A 
git commit -m Second commit. 
-   HEAD=$(git rev-parse --verify HEAD)'
+   HEAD=$(git rev-parse --verify HEAD)
+'
 
 test_expect_success 'git branch --help should not have created a bogus branch' 
'
test_might_fail git branch --help /dev/null /dev/null 2/dev/null 
-- 
1.8.4-fc

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


[PATCH 3/4] t: branch: fix broken chains

2013-08-30 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 t/t3200-branch.sh | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 3134652..d85306f 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -425,14 +425,14 @@ test_expect_success '--set-upstream-to fails on a 
non-ref' '
 test_expect_success 'use --set-upstream-to modify HEAD' '
test_config branch.master.remote foo 
test_config branch.master.merge foo 
-   git branch my12
+   git branch my12 
git branch --set-upstream-to my12 
test $(git config branch.master.remote) = . 
test $(git config branch.master.merge) = refs/heads/my12
 '
 
 test_expect_success 'use --set-upstream-to modify a particular branch' '
-   git branch my13
+   git branch my13 
git branch --set-upstream-to master my13 
test $(git config branch.my13.remote) = . 
test $(git config branch.my13.merge) = refs/heads/master
@@ -443,7 +443,7 @@ test_expect_success '--unset-upstream should fail if given 
a non-existent branch
 '
 
 test_expect_success 'test --unset-upstream on HEAD' '
-   git branch my14
+   git branch my14 
test_config branch.master.remote foo 
test_config branch.master.merge foo 
git branch --set-upstream-to my14 
@@ -465,7 +465,7 @@ test_expect_success '--unset-upstream should fail on 
detached HEAD' '
 '
 
 test_expect_success 'test --unset-upstream on a particular branch' '
-   git branch my15
+   git branch my15 
git branch --set-upstream-to master my14 
git branch --unset-upstream my14 
test_must_fail git config branch.my14.remote 
-- 
1.8.4-fc

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


[PATCH 4/4] t: branch: improve test rollback

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

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

diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index d85306f..3d4f634 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -328,7 +328,7 @@ test_expect_success 'tracking setup fails on non-matching 
refspec' '
 '
 
 test_expect_success 'test tracking setup via config' '
-   git config branch.autosetupmerge true 
+   test_config branch.autosetupmerge true 
git config remote.local.url . 
git config remote.local.fetch refs/heads/*:refs/remotes/local/* 
(git show-ref -q refs/remotes/local/master || git fetch local) 
@@ -338,20 +338,18 @@ test_expect_success 'test tracking setup via config' '
 '
 
 test_expect_success 'test overriding tracking setup via --no-track' '
-   git config branch.autosetupmerge true 
+   test_config branch.autosetupmerge true 
git config remote.local.url . 
git config remote.local.fetch refs/heads/*:refs/remotes/local/* 
(git show-ref -q refs/remotes/local/master || git fetch local) 
git branch --no-track my2 local/master 
-   git config branch.autosetupmerge false 
! test $(git config branch.my2.remote) = local 
! test $(git config branch.my2.merge) = refs/heads/master
 '
 
 test_expect_success 'no tracking without .fetch entries' '
-   git config branch.autosetupmerge true 
+   test_config branch.autosetupmerge true 
git branch my6 s 
-   git config branch.autosetupmerge false 
test -z $(git config branch.my6.remote) 
test -z $(git config branch.my6.merge)
 '
@@ -386,9 +384,8 @@ test_expect_success 'test --track without .fetch entries' '
 '
 
 test_expect_success 'branch from non-branch HEAD w/autosetupmerge=always' '
-   git config branch.autosetupmerge always 
-   git branch my9 HEAD^ 
-   git config branch.autosetupmerge false
+   test_config branch.autosetupmerge always 
+   git branch my9 HEAD^
 '
 
 test_expect_success 'branch from non-branch HEAD w/--track causes failure' '
@@ -405,9 +402,9 @@ test_expect_success '--set-upstream-to fails on multiple 
branches' '
 '
 
 test_expect_success '--set-upstream-to fails on detached HEAD' '
+   test_when_finished git checkout - 
git checkout HEAD^{} 
-   test_must_fail git branch --set-upstream-to master 
-   git checkout -
+   test_must_fail git branch --set-upstream-to master
 '
 
 test_expect_success '--set-upstream-to fails on a missing dst branch' '
@@ -459,9 +456,9 @@ test_expect_success '--unset-upstream should fail on 
multiple branches' '
 '
 
 test_expect_success '--unset-upstream should fail on detached HEAD' '
+   test_when_finished git checkout - 
git checkout HEAD^{} 
-   test_must_fail git branch --unset-upstream 
-   git checkout -
+   test_must_fail git branch --unset-upstream
 '
 
 test_expect_success 'test --unset-upstream on a particular branch' '
@@ -540,7 +537,8 @@ test_expect_success 'checkout -b with -l makes reflog when 
core.logAllRefUpdates
 '
 
 test_expect_success 'avoid ambiguous track' '
-   git config branch.autosetupmerge true 
+   test_when_finished git remote rm ambi1  git remote rm ambi2 
+   test_config branch.autosetupmerge true 
git config remote.ambi1.url lalala 
git config remote.ambi1.fetch refs/heads/lalala:refs/heads/master 
git config remote.ambi2.url lilili 
@@ -552,7 +550,7 @@ test_expect_success 'avoid ambiguous track' '
 test_expect_success 'autosetuprebase local on a tracked local branch' '
git config remote.local.url . 
git config remote.local.fetch refs/heads/*:refs/remotes/local/* 
-   git config branch.autosetuprebase local 
+   test_config branch.autosetuprebase local 
(git show-ref -q refs/remotes/local/o || git fetch local) 
git branch mybase 
git branch --track myr1 mybase 
@@ -564,7 +562,7 @@ test_expect_success 'autosetuprebase local on a tracked 
local branch' '
 test_expect_success 'autosetuprebase always on a tracked local branch' '
git config remote.local.url . 
git config remote.local.fetch refs/heads/*:refs/remotes/local/* 
-   git config branch.autosetuprebase always 
+   test_config branch.autosetuprebase always 
(git show-ref -q refs/remotes/local/o || git fetch local) 
git branch mybase2 
git branch --track myr2 mybase 
@@ -576,7 +574,7 @@ test_expect_success 'autosetuprebase always on a tracked 
local branch' '
 test_expect_success 'autosetuprebase remote on a tracked local branch' '
git config remote.local.url . 
git config remote.local.fetch refs/heads/*:refs/remotes/local/* 
-   git config branch.autosetuprebase remote 
+   

  1   2   >