[PATCH 0/3] Make git add dir/ notice removed dir/file

2013-03-09 Thread Junio C Hamano
This resurrects an ancient stalled topic from last year, rebased on
top of the recent git add -u/-A documentation updates 5cae93566027
(add: Clarify documentation of -A and -u, 2013-03-07) by Greg Price.

The first one is a pure clean-up.  The second one is a preparatory
step that can happen before Git 2.0 to prepare existing users to
form a habit of saying --all (or --no-all) explicitly when
giving a directory name to git add pathspec

Then the last one can be done in Git 2.0 to swap the default.

Junio C Hamano (3):
  builtin/add.c: simplify boolean variables
  git add: start preparing for git add pathspec... to default to -A
  git add pathspec... defaults to -A

 Documentation/git-add.txt | 22 +++---
 builtin/add.c | 36 +---
 t/t2200-add-update.sh |  6 +++---
 3 files changed, 47 insertions(+), 17 deletions(-)

-- 
1.8.2-rc3-203-gc9aaab5

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


[PATCH 1/3] builtin/add.c: simplify boolean variables

2013-03-09 Thread Junio C Hamano
Do not to explicitly initialize static variables to 0 and instead
let BSS take care of it.  Also use OPT_BOOL() to let the command
line arguments set these variables to 0 or 1, instead of the
deprecated OPT_BOOLEAN() aka OPT_COUNTUP().

Signed-off-by: Junio C Hamano gits...@pobox.com
---
 builtin/add.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/builtin/add.c b/builtin/add.c
index 0dd014e..220321b 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -270,23 +270,23 @@ static struct lock_file lock_file;
 static const char ignore_error[] =
 N_(The following paths are ignored by one of your .gitignore files:\n);
 
-static int verbose = 0, show_only = 0, ignored_too = 0, refresh_only = 0;
-static int ignore_add_errors, addremove, intent_to_add, ignore_missing = 0;
+static int verbose, show_only, ignored_too, refresh_only;
+static int ignore_add_errors, addremove, intent_to_add, ignore_missing;
 
 static struct option builtin_add_options[] = {
OPT__DRY_RUN(show_only, N_(dry run)),
OPT__VERBOSE(verbose, N_(be verbose)),
OPT_GROUP(),
-   OPT_BOOLEAN('i', interactive, add_interactive, N_(interactive 
picking)),
-   OPT_BOOLEAN('p', patch, patch_interactive, N_(select hunks 
interactively)),
-   OPT_BOOLEAN('e', edit, edit_interactive, N_(edit current diff and 
apply)),
+   OPT_BOOL('i', interactive, add_interactive, N_(interactive 
picking)),
+   OPT_BOOL('p', patch, patch_interactive, N_(select hunks 
interactively)),
+   OPT_BOOL('e', edit, edit_interactive, N_(edit current diff and 
apply)),
OPT__FORCE(ignored_too, N_(allow adding otherwise ignored files)),
-   OPT_BOOLEAN('u', update, take_worktree_changes, N_(update tracked 
files)),
-   OPT_BOOLEAN('N', intent-to-add, intent_to_add, N_(record only the 
fact that the path will be added later)),
-   OPT_BOOLEAN('A', all, addremove, N_(add changes from all tracked 
and untracked files)),
-   OPT_BOOLEAN( 0 , refresh, refresh_only, N_(don't add, only refresh 
the index)),
-   OPT_BOOLEAN( 0 , ignore-errors, ignore_add_errors, N_(just skip 
files which cannot be added because of errors)),
-   OPT_BOOLEAN( 0 , ignore-missing, ignore_missing, N_(check if - even 
missing - files are ignored in dry run)),
+   OPT_BOOL('u', update, take_worktree_changes, N_(update tracked 
files)),
+   OPT_BOOL('N', intent-to-add, intent_to_add, N_(record only the fact 
that the path will be added later)),
+   OPT_BOOL('A', all, addremove, N_(add changes from all tracked and 
untracked files)),
+   OPT_BOOL( 0 , refresh, refresh_only, N_(don't add, only refresh the 
index)),
+   OPT_BOOL( 0 , ignore-errors, ignore_add_errors, N_(just skip files 
which cannot be added because of errors)),
+   OPT_BOOL( 0 , ignore-missing, ignore_missing, N_(check if - even 
missing - files are ignored in dry run)),
OPT_END(),
 };
 
-- 
1.8.2-rc3-203-gc9aaab5

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


[PATCH 2/3] git add: start preparing for git add pathspec... to default to -A

2013-03-09 Thread Junio C Hamano
When git add subdir/ is run without -u or -A option, e.g.

$ edit subdir/x
$ create subdir/y
$ rm subdir/z
$ git add subdir/

the command does not notice removal of paths (e.g. subdir/z) from
the working tree.  This sometimes confuses new people, as arguably
git add is told to record the current state of subdir/ as a
whole, not the current state of the paths that exist in the working
tree that matches that pathspec (the latter by definition excludes
the state of subdir/z because it does not exist in the working
tree).

Plan to eventually make git add pretend as if -A is given when
there is a pathspec on the command line.  When resolving a conflict
to remove a path, the current code tells you to git rm $path, but
with such a change, you will be able to say git add $path (of
course you can do git add -A $path today).  That means that we can
simplify the advice messages given by git status.  That all will
be in Git 2.0 or later, if we are going to do so.

For that transition to work, people need to learn either to say git
add --no-all subdir/ when they want to ignore the removed paths
like subdir/z, or to say git add -A subdir/ when they want to
take the state of the directory as a whole.

git add without any argument will continue to be a no-op.

Signed-off-by: Junio C Hamano gits...@pobox.com
---
 Documentation/git-add.txt | 14 +-
 builtin/add.c | 45 +++--
 t/t2200-add-update.sh |  6 +++---
 3 files changed, 59 insertions(+), 6 deletions(-)

diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
index b0944e5..5c501a2 100644
--- a/Documentation/git-add.txt
+++ b/Documentation/git-add.txt
@@ -9,7 +9,7 @@ SYNOPSIS
 
 [verse]
 'git add' [-n] [-v] [--force | -f] [--interactive | -i] [--patch | -p]
- [--edit | -e] [--all | [--update | -u]] [--intent-to-add | -N]
+ [--edit | -e] [--[no-]all | [--update | -u]] [--intent-to-add | -N]
  [--refresh] [--ignore-errors] [--ignore-missing] [--]
  [pathspec...]
 
@@ -121,6 +121,18 @@ If no pathspec is given, the current version of Git 
defaults to
 and its subdirectories. This default will change in a future version
 of Git, hence the form without pathspec should not be used.
 
+--no-all::
+   Update the index by adding new files that are unknown to the
+   index and files modified in the working tree, but ignore
+   files that have been removed from the working tree.  This
+   option is a no-op when no pathspec is used.
++
+This option is primarily to help the current users of Git, whose
+git add pathspec... ignores removed files.  In future versions
+of Git, git add pathspec... will be a synonym to git add -A
+pathspec... and git add --no-all pathspec... will behave like
+today's git add pathspec..., ignoring removed files.
+
 -N::
 --intent-to-add::
Record only the fact that the path will be added later. An entry
diff --git a/builtin/add.c b/builtin/add.c
index 220321b..f8f6c9e 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -271,7 +271,11 @@ static const char ignore_error[] =
 N_(The following paths are ignored by one of your .gitignore files:\n);
 
 static int verbose, show_only, ignored_too, refresh_only;
-static int ignore_add_errors, addremove, intent_to_add, ignore_missing;
+static int ignore_add_errors, intent_to_add, ignore_missing;
+
+#define ADDREMOVE_DEFAULT 0 /* Change to 1 in Git 2.0 */
+static int addremove = ADDREMOVE_DEFAULT;
+static int addremove_explicit = -1; /* unspecified */
 
 static struct option builtin_add_options[] = {
OPT__DRY_RUN(show_only, N_(dry run)),
@@ -283,7 +287,7 @@ static struct option builtin_add_options[] = {
OPT__FORCE(ignored_too, N_(allow adding otherwise ignored files)),
OPT_BOOL('u', update, take_worktree_changes, N_(update tracked 
files)),
OPT_BOOL('N', intent-to-add, intent_to_add, N_(record only the fact 
that the path will be added later)),
-   OPT_BOOL('A', all, addremove, N_(add changes from all tracked and 
untracked files)),
+   OPT_BOOL('A', all, addremove_explicit, N_(add changes from all 
tracked and untracked files)),
OPT_BOOL( 0 , refresh, refresh_only, N_(don't add, only refresh the 
index)),
OPT_BOOL( 0 , ignore-errors, ignore_add_errors, N_(just skip files 
which cannot be added because of errors)),
OPT_BOOL( 0 , ignore-missing, ignore_missing, N_(check if - even 
missing - files are ignored in dry run)),
@@ -350,6 +354,18 @@ static void warn_pathless_add(const char *option_name, 
const char *short_name) {
option_name, short_name);
 }
 
+static int directory_given(int argc, const char **argv)
+{
+   struct stat st;
+
+   while (argc--) {
+   if (!lstat(*argv, st)  S_ISDIR(st.st_mode))
+   return 1;
+   argv++;
+   }
+   return 0;
+}
+
 int cmd_add(int argc, const char **argv, const char *prefix)
 {
int 

[PATCH 3/3] git add pathspec... defaults to -A

2013-03-09 Thread Junio C Hamano
Make git add pathspec... notice paths that have been removed
from the working tree, i.e. a synonym to git add -A pathspec

Given that git add pathspec is to update the index with the
state of the named part of the working tree as a whole, it makes it
more intuitive, and also makes it possible to simplify the advice we
give while marking the paths the user finished resolving conflicts
with.  We used to say to record removal as a resolution, remove the
path from the working tree and say 'git rm'; for all other cases,
edit the path in the working tree and say 'git add', but we can now
say update the path in the working tree and say 'git add' instead.

Signed-off-by: Junio C Hamano gits...@pobox.com
---
 Documentation/git-add.txt | 18 +++---
 builtin/add.c | 33 +++--
 2 files changed, 14 insertions(+), 37 deletions(-)

diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
index 5c501a2..e96fa84 100644
--- a/Documentation/git-add.txt
+++ b/Documentation/git-add.txt
@@ -53,8 +53,14 @@ OPTIONS
Files to add content from.  Fileglobs (e.g. `*.c`) can
be given to add all matching files.  Also a
leading directory name (e.g. `dir` to add `dir/file1`
-   and `dir/file2`) can be given to add all files in the
-   directory, recursively.
+   and `dir/file2`) can be given to update the index to
+   match the current state of the directory as a whole (e.g.
+   specifying `dir` will record not just a file `dir/file1`
+   modified in the working tree, a file `dir/file2` added to
+   the working tree, but also a file `dir/file3` removed from
+   the working tree.  Note that older versions of  Git used
+   to ignore removed files; use `--no-all` option if you want
+   to add modified or new files but ignore removed ones.
 
 -n::
 --dry-run::
@@ -127,11 +133,9 @@ of Git, hence the form without pathspec should not be 
used.
files that have been removed from the working tree.  This
option is a no-op when no pathspec is used.
 +
-This option is primarily to help the current users of Git, whose
-git add pathspec... ignores removed files.  In future versions
-of Git, git add pathspec... will be a synonym to git add -A
-pathspec... and git add --no-all pathspec... will behave like
-today's git add pathspec..., ignoring removed files.
+This option is primarily to help users who are used to older
+versions of Git, whose git add pathspec... was a synonym
+to git add --no-all pathspec..., i.e. ignored removed files.
 
 -N::
 --intent-to-add::
diff --git a/builtin/add.c b/builtin/add.c
index f8f6c9e..21c685f 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -273,7 +273,7 @@ N_(The following paths are ignored by one of your 
.gitignore files:\n);
 static int verbose, show_only, ignored_too, refresh_only;
 static int ignore_add_errors, intent_to_add, ignore_missing;
 
-#define ADDREMOVE_DEFAULT 0 /* Change to 1 in Git 2.0 */
+#define ADDREMOVE_DEFAULT 1
 static int addremove = ADDREMOVE_DEFAULT;
 static int addremove_explicit = -1; /* unspecified */
 
@@ -354,18 +354,6 @@ static void warn_pathless_add(const char *option_name, 
const char *short_name) {
option_name, short_name);
 }
 
-static int directory_given(int argc, const char **argv)
-{
-   struct stat st;
-
-   while (argc--) {
-   if (!lstat(*argv, st)  S_ISDIR(st.st_mode))
-   return 1;
-   argv++;
-   }
-   return 0;
-}
-
 int cmd_add(int argc, const char **argv, const char *prefix)
 {
int exit_status = 0;
@@ -401,24 +389,9 @@ int cmd_add(int argc, const char **argv, const char 
*prefix)
if (addremove  take_worktree_changes)
die(_(-A and -u are mutually incompatible));
 
-   /*
-* Warn when git add pathspec... was given without -u or -A
-* and pathspec... contains a directory name.
-*/
-   if (!take_worktree_changes  addremove_explicit  0 
-   directory_given(argc, argv))
-   warning(_(In Git 2.0, 'git add pathspec...' will also update 
the\n
- index for paths removed from the working tree that 
match\n
- the given pathspec. If you want to 'add' only 
changed\n
- or newly created paths, say 'git add --no-all 
pathspec...'
-  instead.));
-
if (!take_worktree_changes  addremove_explicit  0  argc)
-   /*
-* Turn git add pathspec... to git add -A pathspec...
-* in Git 2.0 but not yet
-*/
-   ; /* addremove = 1; */
+   /* Turn git add pathspec... to git add -A pathspec... */
+   addremove = 1;
 
if (!show_only  ignore_missing)
die(_(Option --ignore-missing can only be used together with 
--dry-run));
-- 
1.8.2-rc3-203-gc9aaab5

--
To unsubscribe from this list: 

[PATCH v2 0/2] git add -u/-A from future

2013-03-09 Thread Junio C Hamano
Here are two future steps to update the behaviour of add -u/-A run
without pathspec towards Git 2.0; the first step may probably be
optional, but it is included for completeness.

Rebased on top of the recent git add -u/-A documentation updates
5cae93566027 (add: Clarify documentation of -A and -u, 2013-03-07)
by Greg Price.

Junio C Hamano (2):
  require pathspec for git add -u/-A
  git add: -u/-A now affects the entire working tree

 Documentation/git-add.txt | 16 
 builtin/add.c | 49 ---
 2 files changed, 12 insertions(+), 53 deletions(-)

-- 
1.8.2-rc3-203-gc9aaab5

--
To unsubscribe from this list: send the line 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/2] require pathspec for git add -u/-A

2013-03-09 Thread Junio C Hamano
As promised in 0fa2eb530fb7 (add: warn when -u or -A is used without
pathspec, 2013-01-28), git add -u/-A that is run without pathspec
in a subdirectory will stop working sometime before Git 2.0, to wean
users off of the old default, in preparation for adopting the new
default in Git 2.0.

Signed-off-by: Junio C Hamano gits...@pobox.com
---
 Documentation/git-add.txt | 24 
 builtin/add.c | 38 ++
 2 files changed, 34 insertions(+), 28 deletions(-)

diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
index b0944e5..b849b78 100644
--- a/Documentation/git-add.txt
+++ b/Documentation/git-add.txt
@@ -104,10 +104,14 @@ apply to the index. See EDITING PATCHES below.
pathspec.  This removes as well as modifies index entries to
match the working tree, but adds no new files.
 +
-If no pathspec is given, the current version of Git defaults to
-.; in other words, update all tracked files in the current directory
-and its subdirectories. This default will change in a future version
-of Git, hence the form without pathspec should not be used.
+If no pathspec is given when `-u` option is used, Git used
+to update all tracked files in the current directory and its
+subdirectories. We would eventually want to change this to operate
+on the entire working tree, not limiting it to the current
+directory, to make it consistent with `git commit -a` and other
+commands.  In order to avoid harming users who are used to the old
+default, Git *errors out* when no pathspec is given to train their
+fingers to explicitly type `git add -u .` when they mean it.
 
 -A::
 --all::
@@ -116,10 +120,14 @@ of Git, hence the form without pathspec should not be 
used.
entry.  This adds, modifies, and removes index entries to
match the working tree.
 +
-If no pathspec is given, the current version of Git defaults to
-.; in other words, update all files in the current directory
-and its subdirectories. This default will change in a future version
-of Git, hence the form without pathspec should not be used.
+If no pathspec is given when `-A` option is used, Git used
+to update all files in the current directory and its
+subdirectories. We would eventually want to change this to operate
+on the entire working tree, not limiting it to the current
+directory, to make it consistent with `git commit -a` and other
+commands.  In order to avoid harming users who are used to the old
+default, Git *errors out* when no pathspec is given to train their
+fingers to explicitly type `git add -A .` when they mean it.
 
 -N::
 --intent-to-add::
diff --git a/builtin/add.c b/builtin/add.c
index 0dd014e..4b9d57c 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -321,30 +321,28 @@ static int add_files(struct dir_struct *dir, int flags)
return exit_status;
 }
 
-static void warn_pathless_add(const char *option_name, const char *short_name) 
{
+static void die_on_pathless_add(const char *option_name, const char 
*short_name)
+{
/*
 * To be consistent with git add -p and most Git
 * commands, we should default to being tree-wide, but
 * this is not the original behavior and can't be
 * changed until users trained themselves not to type
-* git add -u or git add -A. For now, we warn and
-* keep the old behavior. Later, this warning can be
-* turned into a die(...), and eventually we may
-* reallow the command with a new behavior.
+* git add -u or git add -A. In the previous release,
+* we kept the old behavior but gave a big warning.
 */
-   warning(_(The behavior of 'git add %s (or %s)' with no path argument 
from a\n
- subdirectory of the tree will change in Git 2.0 and should 
not be used anymore.\n
- To add content for the whole tree, run:\n
- \n
-   git add %s :/\n
-   (or git add %s :/)\n
- \n
- To restrict the command to the current directory, run:\n
- \n
-   git add %s .\n
-   (or git add %s .)\n
- \n
- With the current Git version, the command is restricted to 
the current directory.),
+   die(_(The behavior of 'git add %s (or %s)' with no path argument from 
a\n
+ subdirectory of the tree will change in Git 2.0 and should not 
be 
+ used anymore.\n
+ To add content for the whole tree, run:\n
+ \n
+   git add %s :/\n
+   (or git add %s :/)\n
+ \n
+ To restrict the command to the current directory, run:\n
+ \n
+   git add %s .\n
+   (or git add %s .)),
option_name, short_name,
option_name, short_name,
option_name, short_name);
@@ -392,8 +390,8 @@ int cmd_add(int argc, 

[PATCH v2 2/2] git add: -u/-A now affects the entire working tree

2013-03-09 Thread Junio C Hamano
As promised in 0fa2eb530fb7 (add: warn when -u or -A is used without
pathspec, 2013-01-28), in Git 2.0, git add -u/-A that is run
without pathspec in a subdirectory updates all updated paths in the
entire working tree, not just the current directory and its
subdirectories.

Signed-off-by: Junio C Hamano gits...@pobox.com
---
 Documentation/git-add.txt | 24 
 builtin/add.c | 47 ---
 2 files changed, 12 insertions(+), 59 deletions(-)

diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
index b849b78..02b99cb 100644
--- a/Documentation/git-add.txt
+++ b/Documentation/git-add.txt
@@ -104,14 +104,10 @@ apply to the index. See EDITING PATCHES below.
pathspec.  This removes as well as modifies index entries to
match the working tree, but adds no new files.
 +
-If no pathspec is given when `-u` option is used, Git used
-to update all tracked files in the current directory and its
-subdirectories. We would eventually want to change this to operate
-on the entire working tree, not limiting it to the current
-directory, to make it consistent with `git commit -a` and other
-commands.  In order to avoid harming users who are used to the old
-default, Git *errors out* when no pathspec is given to train their
-fingers to explicitly type `git add -u .` when they mean it.
+If no pathspec is given when `-u` option is used, all
+tracked files in the entire working tree are updated (old versions
+of Git used to limit the update to the current directory and its
+subdirectories).
 
 -A::
 --all::
@@ -120,14 +116,10 @@ fingers to explicitly type `git add -u .` when they mean 
it.
entry.  This adds, modifies, and removes index entries to
match the working tree.
 +
-If no pathspec is given when `-A` option is used, Git used
-to update all files in the current directory and its
-subdirectories. We would eventually want to change this to operate
-on the entire working tree, not limiting it to the current
-directory, to make it consistent with `git commit -a` and other
-commands.  In order to avoid harming users who are used to the old
-default, Git *errors out* when no pathspec is given to train their
-fingers to explicitly type `git add -A .` when they mean it.
+If no pathspec is given when `-A` option is used, all
+files in the entire working tree are updated (old versions
+of Git used to limit the update to the current directory and its
+subdirectories).
 
 -N::
 --intent-to-add::
diff --git a/builtin/add.c b/builtin/add.c
index 4b9d57c..6cd063f 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -321,33 +321,6 @@ static int add_files(struct dir_struct *dir, int flags)
return exit_status;
 }
 
-static void die_on_pathless_add(const char *option_name, const char 
*short_name)
-{
-   /*
-* To be consistent with git add -p and most Git
-* commands, we should default to being tree-wide, but
-* this is not the original behavior and can't be
-* changed until users trained themselves not to type
-* git add -u or git add -A. In the previous release,
-* we kept the old behavior but gave a big warning.
-*/
-   die(_(The behavior of 'git add %s (or %s)' with no path argument from 
a\n
- subdirectory of the tree will change in Git 2.0 and should not 
be 
- used anymore.\n
- To add content for the whole tree, run:\n
- \n
-   git add %s :/\n
-   (or git add %s :/)\n
- \n
- To restrict the command to the current directory, run:\n
- \n
-   git add %s .\n
-   (or git add %s .)),
-   option_name, short_name,
-   option_name, short_name,
-   option_name, short_name);
-}
-
 int cmd_add(int argc, const char **argv, const char *prefix)
 {
int exit_status = 0;
@@ -358,8 +331,6 @@ int cmd_add(int argc, const char **argv, const char *prefix)
int add_new_files;
int require_pathspec;
char *seen = NULL;
-   const char *option_with_implicit_dot = NULL;
-   const char *short_option_with_implicit_dot = NULL;
 
git_config(add_config, NULL);
 
@@ -379,21 +350,11 @@ int cmd_add(int argc, const char **argv, const char 
*prefix)
die(_(-A and -u are mutually incompatible));
if (!show_only  ignore_missing)
die(_(Option --ignore-missing can only be used together with 
--dry-run));
-   if (addremove) {
-   option_with_implicit_dot = --all;
-   short_option_with_implicit_dot = -A;
-   }
-   if (take_worktree_changes) {
-   option_with_implicit_dot = --update;
-   short_option_with_implicit_dot = -u;
-   }
-   if (option_with_implicit_dot  !argc) {
-   static const char *here[2] = { ., NULL };
-   if (prefix)
-   

[PATCH] Replace strcmp_icase with strequal_icase

2013-03-09 Thread Fredrik Gustafsson
To improve performance.
git status before:
user0m0.020s
user0m0.024s
user0m0.024s
user0m0.020s
user0m0.024s
user0m0.028s
user0m0.024s
user0m0.024s
user0m0.016s
user0m0.028s

git status after:
user0m0.012s
user0m0.008s
user0m0.008s
user0m0.008s
user0m0.008s
user0m0.008s
user0m0.008s
user0m0.004s
user0m0.008s
user0m0.016s

Signed-off-by: Fredrik Gustafsson iv...@iveqy.com
---
 dir.c | 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/dir.c b/dir.c
index 57394e4..2b801e8 100644
--- a/dir.c
+++ b/dir.c
@@ -37,6 +37,17 @@ int fnmatch_icase(const char *pattern, const char *string, 
int flags)
return fnmatch(pattern, string, flags | (ignore_case ? FNM_CASEFOLD : 
0));
 }
 
+int strequal_icase(const char *first, const char *second)
+{
+   while (*first  *second) {
+   if( toupper(*first) != toupper(*second))
+   break;
+   first++;
+   second++;
+   }
+   return toupper(*first) == toupper(*second);
+}
+
 inline int git_fnmatch(const char *pattern, const char *string,
   int flags, int prefix)
 {
@@ -626,11 +637,11 @@ int match_basename(const char *basename, int basenamelen,
   int flags)
 {
if (prefix == patternlen) {
-   if (!strcmp_icase(pattern, basename))
+   if (!strequal_icase(pattern, basename))
return 1;
} else if (flags  EXC_FLAG_ENDSWITH) {
if (patternlen - 1 = basenamelen 
-   !strcmp_icase(pattern + 1,
+   !strequal_icase(pattern + 1,
  basename + basenamelen - patternlen + 1))
return 1;
} else {
@@ -663,7 +674,7 @@ int match_pathname(const char *pathname, int pathlen,
 */
if (pathlen  baselen + 1 ||
(baselen  pathname[baselen] != '/') ||
-   strncmp_icase(pathname, base, baselen))
+   strequal_icase(pathname, base))
return 0;
 
namelen = baselen ? pathlen - baselen - 1 : pathlen;
-- 
1.8.1.5

--
To unsubscribe from this list: send the line 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/3] match_basename: use strncmp instead of strcmp

2013-03-09 Thread Fredrik Gustafsson
On Fri, Mar 08, 2013 at 11:50:04PM -0800, Junio C Hamano wrote:
 At the same time, I wonder if we can take advantage of the fact that
 these call sites only care about equality and not ordering.

I did an RFC-patch for that (that I mistakenly didn't sent as a reply to
this e-mail). And I believe that you're correct. My solution is inspired
of curl's strequal.

Is the reason for git not to care about lower/upper-case for beeing able
to support windows? Or is there any other smart reason?

I was also thinking about discarding files by looking at their
modification date. If the modification timestamp is older than/or equal to
the latest commit, there's probably no reason for examine that file any
further. I'm not sure about the side effects this may imply though. I
think they can be quite nasty. Is this something worth digging more in
or am I already on the wrong path?

-- 
Med vänliga hälsningar
Fredrik Gustafsson

tel: 0733-608274
e-post: iv...@iveqy.com
--
To unsubscribe from this list: send the line 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] Replace strcmp_icase with strequal_icase

2013-03-09 Thread Fredrik Gustafsson
Please ignore last e-mail. Sorry for the disturbance.

-- 
Med vänliga hälsningar
Fredrik Gustafsson

tel: 0733-608274
e-post: iv...@iveqy.com
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] match_pathname: avoid calling strncmp if baselen is 0

2013-03-09 Thread Antoine Pelisse
 diff --git a/dir.c b/dir.c
 index 57394e4..669cf80 100644
 --- a/dir.c
 +++ b/dir.c
 @@ -663,7 +663,7 @@ int match_pathname(const char *pathname, int pathlen,
  */
 if (pathlen  baselen + 1 ||
 (baselen  pathname[baselen] != '/') ||
 -   strncmp_icase(pathname, base, baselen))
 +   (baselen  strncmp_icase(pathname, base, baselen)))

Shouldn't you factorize by baselen here ? For readability reasons, not
performance of course.

 return 0;

 namelen = baselen ? pathlen - baselen - 1 : pathlen;
--
To unsubscribe from this list: send the line 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/3] match_basename: use strncmp instead of strcmp

2013-03-09 Thread Duy Nguyen
On Sat, Mar 9, 2013 at 2:50 PM, Junio C Hamano gits...@pobox.com wrote:
 Nguyễn Thái Ngọc Duy  pclo...@gmail.com writes:

 strncmp provides length information, compared to strcmp, which could
 be taken advantage by the implementation. Even better, we could check
 if the lengths are equal before calling strncmp, eliminating a bit of
 strncmp calls.

 I think I am a bit slower than my usual self tonight, but I am
 utterly confused by the above.

 strncmp() compares _only_ up to the first n bytes, so when you are
 using it for equality, it is not we could check length, but is we
 MUST check they match to the length of the shorter string, if you
 want to obtain not just faster but correct result.

 Am I mistaken?

Yeap, the description is a bit misleading. Although you could get away
with length check by doing !strncmp(a, b, strlen(a)+1).

 Even if you are using strcmp() that yields ordering not just
 equality, it can return a correct result as soon as it hits the
 first bytes that are different; I doubt using strncmp() contributes
 to the performance very much.  Comparing lengths before doing
 byte-for-byte comparison could help because you can reject two
 strings with different lengths without looking at them.

 At the same time, I wonder if we can take advantage of the fact that
 these call sites only care about equality and not ordering.

I tried to push it further and compare hash before do the actual
string comparison. It slowed things down (hopefully because the cost
of hashing, the same one from name-hash.c, not because I did it
wrong).
-- 
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] Replace strcmp_icase with strequal_icase

2013-03-09 Thread Duy Nguyen
On Sat, Mar 09, 2013 at 09:42:54AM +0100, Fredrik Gustafsson wrote:
 To improve performance.
 git status before:
 user0m0.020s
 user0m0.024s
 user0m0.024s
 user0m0.020s
 user0m0.024s
 user0m0.028s
 user0m0.024s
 user0m0.024s
 user0m0.016s
 user0m0.028s
 
 git status after:
 user0m0.012s
 user0m0.008s
 user0m0.008s
 user0m0.008s
 user0m0.008s
 user0m0.008s
 user0m0.008s
 user0m0.004s
 user0m0.008s
 user0m0.016s

I tested a slightly different version that checks ignore_case, inlines
if possible and replaces one more strncmp_icase call site (the top
call site in webkit.git). The numbers are impressive (well not as
impressive as yours, but I guess it depends on the actual .gitignore
patterns). On top of my 3/3

before  after
user0m0.508s0m0.392s
user0m0.511s0m0.394s
user0m0.513s0m0.405s
user0m0.516s0m0.407s
user0m0.516s0m0.407s
user0m0.518s0m0.410s
user0m0.519s0m0.412s
user0m0.524s0m0.415s
user0m0.527s0m0.415s
user0m0.534s0m0.417s

I still need to run the test suite. Then maybe reroll my series with
this.

-- 8 --
diff --git a/dir.c b/dir.c
index 2a91d14..6a9b4b7 100644
--- a/dir.c
+++ b/dir.c
@@ -21,6 +21,24 @@ static int read_directory_recursive(struct dir_struct *dir, 
const char *path, in
int check_only, const struct path_simplify *simplify);
 static int get_dtype(struct dirent *de, const char *path, int len);
 
+static inline strnequal_icase(const char *first, const char *second, int 
length)
+{
+   if (ignore_case) {
+   while (length  toupper(*first) == toupper(*second)) {
+   first++;
+   second++;
+   length--;
+   }
+   } else {
+   while (length  *first == *second) {
+   first++;
+   second++;
+   length--;
+   }
+   }
+   return length == 0;
+}
+
 inline int git_fnmatch(const char *pattern, const char *string,
   int flags, int prefix)
 {
@@ -611,11 +629,11 @@ int match_basename(const char *basename, int basenamelen,
 {
if (prefix == patternlen) {
if (patternlen == basenamelen 
-   !strncmp_icase(pattern, basename, patternlen))
+   strnequal_icase(pattern, basename, patternlen))
return 1;
} else if (flags  EXC_FLAG_ENDSWITH) {
if (patternlen - 1 = basenamelen 
-   !strncmp_icase(pattern + 1,
+   strnequal_icase(pattern + 1,
   basename + basenamelen - patternlen + 1,
   patternlen - 1))
return 1;
@@ -649,7 +667,7 @@ int match_pathname(const char *pathname, int pathlen,
 */
if (pathlen  baselen + 1 ||
(baselen  pathname[baselen] != '/') ||
-   (baselen  strncmp_icase(pathname, base, baselen)))
+   (baselen  !strnequal_icase(pathname, base, baselen)))
return 0;
 
namelen = baselen ? pathlen - baselen - 1 : pathlen;
@@ -663,7 +681,7 @@ int match_pathname(const char *pathname, int pathlen,
if (prefix  namelen)
return 0;
 
-   if (strncmp_icase(pattern, name, prefix))
+   if (!strnequal_icase(pattern, name, prefix))
return 0;
pattern += prefix;
name+= prefix;
-- 8 --
--
To unsubscribe from this list: send the line 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] Replace strcmp_icase with strequal_icase

2013-03-09 Thread Duy Nguyen
On Sat, Mar 9, 2013 at 3:42 PM, Fredrik Gustafsson iv...@iveqy.com wrote:
 To improve performance.

BTW, by rolling our own string comparison, we may lose certain
optimizations done by C library. In case of glibc, it may choose to
run an sse4.2 version where 16 bytes are compared at a time. Maybe we
encounter string not equal much often than string equal and such
an optimization is unncessary, I don't know. Measured numbers say it's
unncessary as my cpu supports sse4.2.
-- 
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: Memory corruption when rebasing with git version 1.8.1.5 on arch

2013-03-09 Thread Bernhard Posselt

On 03/09/2013 05:48 AM, Jeff King wrote:

On Sat, Mar 09, 2013 at 01:08:32AM +0100, Bernhard Posselt wrote:


The problem is likely happening in a sub-command of git-pull, so
valgrind isn't reporting it. Can you try re-running with
valgrind --trace-children=yes, or alternatively narrow down the
problematic command by setting GIT_TRACE=1 in the environment?

Heres the output with GIT_TRACE=1, the valgrind log has 4000 lines.
If you should still require the valgrind log, please tell me.

Hmm, the GIT_TRACE output was less clear than I had hoped; it's unclear
to me which git program is actually dying (my guess is git apply, and
we are squelching stderr, which is where the GIT_TRACE output is going).

Can you try it once again with something like GIT_TRACE=/tmp/foo.out,
which will make sure we record the trace directly, even if stderr ends
up redirected?

Also, I can almost reproduce here, as PatrickHeller/core.git is public.
However, I suspect the problem is particular to your work built on top,
which looks like it is at commit 0525bbd73c9015499ba92d1ac654b980aaca35b2.
Is it possible for you to make that commit available on a temporary
branch?

-Peff

 commit available on a temporary branch?
What do you mean exactly by that?

I've made copies of both repositories on github.

Heres a copy of the basic repo: 
https://github.com/Raydiation/memorycorruption
Heres my clone of the repo that i pull from: 
https://github.com/Raydiation/core


Basically:

git clone https://github.com/Raydiation/memorycorruption
cd memorycorruption
git pull --rebase https://github.com/Raydiation/core

Heres the output of the GIT_TRACE file

trace: built-in: git 'branch'
trace: built-in: git 'branch' '--no-color'
trace: built-in: git 'status'
trace: exec: 'git-pull' '--rebase' 'https://github.com/Raydiation/core' 
'master'
trace: run_command: 'git-pull' '--rebase' 
'https://github.com/Raydiation/core' 'master'

trace: built-in: git 'rev-parse' '--git-dir'
trace: built-in: git 'rev-parse' '--is-bare-repository'
trace: built-in: git 'rev-parse' '--show-toplevel'
trace: built-in: git 'ls-files' '-u'
trace: built-in: git 'symbolic-ref' '-q' 'HEAD'
trace: built-in: git 'config' '--bool' 'branch.master.rebase'
trace: built-in: git 'config' '--bool' 'pull.rebase'
trace: built-in: git 'rev-parse' '-q' '--verify' 'HEAD'
trace: built-in: git 'rev-parse' '--verify' 'HEAD'
trace: built-in: git 'update-index' '-q' '--ignore-submodules' '--refresh'
trace: built-in: git 'diff-files' '--quiet' '--ignore-submodules'
trace: built-in: git 'diff-index' '--cached' '--quiet' 
'--ignore-submodules' 'HEAD' '--'

trace: built-in: git 'rev-parse' '-q' '--git-dir'
trace: built-in: git 'rev-parse' '-q' '--verify' 
'refs/remotes/https://github.com/Raydiation/core/master'

trace: built-in: git 'rev-parse' '-q' '--verify' 'HEAD'
trace: built-in: git 'fetch' '--update-head-ok' 
'https://github.com/Raydiation/core' 'master'
trace: run_command: 'git-remote-https' 
'https://github.com/Raydiation/core' 'https://github.com/Raydiation/core'
trace: run_command: 'rev-list' '--objects' '--stdin' '--not' '--all' 
'--quiet'
trace: exec: 'git' 'rev-list' '--objects' '--stdin' '--not' '--all' 
'--quiet'
trace: built-in: git 'rev-list' '--objects' '--stdin' '--not' '--all' 
'--quiet'
trace: run_command: 'fetch-pack' '--stateless-rpc' '--stdin' 
'--lock-pack' '--thin' 'https://github.com/Raydiation/core/'
trace: exec: 'git' 'fetch-pack' '--stateless-rpc' '--stdin' 
'--lock-pack' '--thin' 'https://github.com/Raydiation/core/'
trace: built-in: git 'fetch-pack' '--stateless-rpc' '--stdin' 
'--lock-pack' '--thin' 'https://github.com/Raydiation/core/'

trace: run_command: 'unpack-objects' '--pack_header=2,3'
trace: exec: 'git' 'unpack-objects' '--pack_header=2,3'
trace: built-in: git 'unpack-objects' '--pack_header=2,3'
trace: run_command: 'rev-list' '--objects' '--stdin' '--not' '--all'
trace: exec: 'git' 'rev-list' '--objects' '--stdin' '--not' '--all'
trace: built-in: git 'rev-list' '--objects' '--stdin' '--not' '--all'
trace: built-in: git 'rev-parse' '-q' '--verify' 'HEAD'
trace: built-in: git 'show-branch' '--merge-base' 'refs/heads/master' 
'd686039828089d53fb42e42046d7a9a3992a0507'

trace: built-in: git 'fmt-merge-msg'
trace: built-in: git 'rev-parse' '--parseopt' '--' '--onto' 
'd686039828089d53fb42e42046d7a9a3992a0507' 
'd686039828089d53fb42e42046d7a9a3992a0507'

trace: built-in: git 'rev-parse' '--git-dir'
trace: built-in: git 'rev-parse' '--is-bare-repository'
trace: built-in: git 'rev-parse' '--show-toplevel'
trace: built-in: git 'config' '--bool' 'rebase.stat'
trace: built-in: git 'config' '--bool' 'rebase.autosquash'
trace: built-in: git 'rev-parse' '--verify' 
'd686039828089d53fb42e42046d7a9a3992a0507^0'
trace: built-in: git 'rev-parse' '--verify' 
'd686039828089d53fb42e42046d7a9a3992a0507^0'

trace: built-in: git 'symbolic-ref' '-q' 'HEAD'
trace: built-in: git 'rev-parse' '--verify' 'master^0'
trace: built-in: git 'rev-parse' '--verify' 'HEAD'
trace: built-in: git 

Re: [PATCH] Replace strcmp_icase with strequal_icase

2013-03-09 Thread Duy Nguyen
On Sat, Mar 9, 2013 at 5:40 PM, Duy Nguyen pclo...@gmail.com wrote:
 On Sat, Mar 9, 2013 at 3:42 PM, Fredrik Gustafsson iv...@iveqy.com wrote:
 To improve performance.

 BTW, by rolling our own string comparison, we may lose certain
 optimizations done by C library. In case of glibc, it may choose to
 run an sse4.2 version where 16 bytes are compared at a time. Maybe we
 encounter string not equal much often than string equal and such
 an optimization is unncessary, I don't know. Measured numbers say it's
 unncessary as my cpu supports sse4.2.

Another problem is locale. Git's toupper() does not care about locale,
which should be fine in most cases. strcasecmp is locale-aware, our
new str[n]equal_icase is not. It probably does not matter for
(ascii-based) pathnames, I guess. core.ignorecase users, any comments?
-- 
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] Replace strcmp_icase with strequal_icase

2013-03-09 Thread Fredrik Gustafsson
On Sat, Mar 09, 2013 at 05:54:45PM +0700, Duy Nguyen wrote:
 On Sat, Mar 9, 2013 at 5:40 PM, Duy Nguyen pclo...@gmail.com wrote:
  On Sat, Mar 9, 2013 at 3:42 PM, Fredrik Gustafsson iv...@iveqy.com wrote:
  To improve performance.
 
  BTW, by rolling our own string comparison, we may lose certain
  optimizations done by C library. In case of glibc, it may choose to
  run an sse4.2 version where 16 bytes are compared at a time. Maybe we
  encounter string not equal much often than string equal and such
  an optimization is unncessary, I don't know. Measured numbers say it's
  unncessary as my cpu supports sse4.2.
 
 Another problem is locale. Git's toupper() does not care about locale,
 which should be fine in most cases. strcasecmp is locale-aware, our
 new str[n]equal_icase is not. It probably does not matter for
 (ascii-based) pathnames, I guess. core.ignorecase users, any comments?
 -- 
 Duy

Actually when implemented a str[n]equal_icase that actually should work.
I break the test suite when trying to replace
strncmp_icase(pathname, base, baselen)) on line 711 in dir.c and I don't
get any significant improvements.

I like work in this area though, slow commit's are my worst git problem.
I often have to wait 10s. for a commit to be calculated.


-- 
Med vänliga hälsningar
Fredrik Gustafsson

tel: 0733-608274
e-post: iv...@iveqy.com


From c5d1f436cdbe7b12c67e81cf1d2904d1fb2e9b6b Mon Sep 17 00:00:00 2001
From: Fredrik Gustafsson iv...@iveqy.com
Date: Sat, 9 Mar 2013 09:27:16 +0100
Subject: [PATCH] Replace strcmp_icase with strequal_icase

To improve performance.
git status before:
user0m0.020s
user0m0.024s
user0m0.024s
user0m0.020s
user0m0.024s
user0m0.028s
user0m0.024s
user0m0.024s
user0m0.016s
user0m0.028s

git status after:
wip

Tried to replace strncmp_icase on line 711 in dir.c but then failed to
run the testsuite. Did not got any relevant speed improvements of this.
---
 dir.c |   49 +++--
 1 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/dir.c b/dir.c
index 57394e4..aace36a 100644
--- a/dir.c
+++ b/dir.c
@@ -37,6 +37,51 @@ int fnmatch_icase(const char *pattern, const char *string, 
int flags)
return fnmatch(pattern, string, flags | (ignore_case ? FNM_CASEFOLD : 
0));
 }
 
+int strnequal_icase(const char *first, const char *second, size_t count)
+{
+   if (ignore_case) {
+   while (*first  *second  count) {
+   if( toupper(*first) != toupper(*second))
+   break;
+   first++;
+   second++;
+   count--;
+   }
+   return toupper(*first) == toupper(*second);
+   } else {
+   while (*first  *second  count) {
+   if( *first != *second)
+   break;
+   first++;
+   second++;
+   count--;
+   }
+   return *first == *second;
+   }
+
+}
+
+int strequal_icase(const char *first, const char *second)
+{
+   if (ignore_case) {
+   while (*first  *second) {
+   if( toupper(*first) != toupper(*second))
+   break;
+   first++;
+   second++;
+   }
+   return toupper(*first) == toupper(*second);
+   } else {
+   while (*first  *second) {
+   if( *first != *second)
+   break;
+   first++;
+   second++;
+   }
+   return *first == *second;
+   }
+}
+
 inline int git_fnmatch(const char *pattern, const char *string,
   int flags, int prefix)
 {
@@ -626,11 +671,11 @@ int match_basename(const char *basename, int basenamelen,
   int flags)
 {
if (prefix == patternlen) {
-   if (!strcmp_icase(pattern, basename))
+   if (strequal_icase(pattern, basename))
return 1;
} else if (flags  EXC_FLAG_ENDSWITH) {
if (patternlen - 1 = basenamelen 
-   !strcmp_icase(pattern + 1,
+   strequal_icase(pattern + 1,
  basename + basenamelen - patternlen + 1))
return 1;
} else {
-- 
1.7.2.5

--
To unsubscribe from this list: send the line 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: rebase: strange failures to apply patc 3-way

2013-03-09 Thread Max Horn

On 08.03.2013, at 20:20, Andrew Wong wrote:

 On 3/8/13, Max Horn m...@quendi.de wrote:
 Same result, it works fine.
 
 Just shooting in the dark here... I wonder if there's some background
 process running in OS X that's messing with the files/directories
 while rebase is working... backup, virus scan, etc? Or maybe some
 programs that you're using at the same time? Maybe also make sure you
 don't have any programs (shells, editors, etc.) opened that's
 accessing those files/directories?

I am pretty sure no other programs are accessing those files at the same time. 
But just to make sure I quite most programs. No virus scanner running. No 
backup running -- although, OS X automatically runs hourly backups as part of 
Time Machine... So just to be triple certain, I black listed the repos dir in 
both the Time Machine backup service and the Spotlight indexing service.

No diference. In the end I even did a reboot, but that made no differences 
either (which I am quite relieved about, I must say ;-).


 
 Does the error always happen at COMMIT A and COMMIT B? Or is it all
 over the place?

It tends to fail in separate places, but eventually stabilizes. E.g. I just 
did a couple test rebases, and it failed twice in commit 14, then the third 
time in commit 15 (which underlines once more that the failures are 
inappropriate).

The fourth time, something new and weird happened:

$ git rebase --abort
$ git rebase NEW-PARENT 
Cannot rebase: You have unstaged changes.
Please commit or stash them.
$

This is quite suspicious. It appears that git for some reason things a file is 
dirty when it isn't. That could explain the other rebase failures too, couldn't 
it? But what might cause such a thing?


I checked with git st and it reported no changed files. Executing the 
rebase once again then worked as before... I.e. it got stuck in commit 15. 
The next time it got till commit 16. Then back to commit 15. Etc. Now it is 
getting stuck on commit 17 (but it doesn't always go up as it did right now).


 
 In cases where COMMIT A succeeded, did it say it did a 3-way merge? Or
 was it exactly as the output in your original message? i.e. no message
 at all

It's always a variation of the same message as shown in my original email. I.e.:

Applying: ...
...
Applying: commit XYZ
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
error: Your local changes to the following files would be overwritten by merge:
some/file
Please, commit your changes or stash them before you can merge.
Aborting
Failed to merge in the changes.
Patch failed at 0015 commit XYZ
The copy of the patch that failed is found in:
   /path/to/repos/.git/rebase-apply/patch





Thanks,
Max--
To unsubscribe from this list: send the line 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] Replace strcmp_icase with strequal_icase

2013-03-09 Thread Duy Nguyen
On Sat, Mar 9, 2013 at 6:08 PM, Fredrik Gustafsson iv...@iveqy.com wrote:
 Actually when implemented a str[n]equal_icase that actually should work.
 I break the test suite when trying to replace
 strncmp_icase(pathname, base, baselen)) on line 711 in dir.c and I don't
 get any significant improvements.

Hmm.. mine passed the test suite.

 I like work in this area though, slow commit's are my worst git problem.
 I often have to wait 10s. for a commit to be calculated.

Personally I don't accept any often used git commands taking more than
1 second (in hot cache case). What commands do you use? What's the
size of the repository in terms of tracked/untracked files?
-- 
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] Replace strcmp_icase with strequal_icase

2013-03-09 Thread Fredrik Gustafsson
On Sat, Mar 09, 2013 at 07:05:37PM +0700, Duy Nguyen wrote:
 On Sat, Mar 9, 2013 at 6:08 PM, Fredrik Gustafsson iv...@iveqy.com wrote:
  Actually when implemented a str[n]equal_icase that actually should work.
  I break the test suite when trying to replace
  strncmp_icase(pathname, base, baselen)) on line 711 in dir.c and I don't
  get any significant improvements.
 
 Hmm.. mine passed the test suite.

Using my patch or your own code? Maybe I just did something wrong. Could
you see any improvements in speed?

 
  I like work in this area though, slow commit's are my worst git problem.
  I often have to wait 10s. for a commit to be calculated.
 
 Personally I don't accept any often used git commands taking more than
 1 second (in hot cache case). What commands do you use? What's the
 size of the repository in terms of tracked/untracked files?

It's a small repository, 100 MB. However I have a slow hdd which is
almost full. I often add one file and make an one-line change to an
other file and then do a git commit -a. That will make git to look
through the whole repo, which isn't in the kernel RAM cache but needs to
be reed from the hdd.

-- 
Med vänliga hälsningar
Fredrik Gustafsson

tel: 0733-608274
e-post: iv...@iveqy.com
--
To unsubscribe from this list: send the line 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] Replace strcmp_icase with strequal_icase

2013-03-09 Thread Duy Nguyen
On Sat, Mar 9, 2013 at 7:22 PM, Fredrik Gustafsson iv...@iveqy.com wrote:
 On Sat, Mar 09, 2013 at 07:05:37PM +0700, Duy Nguyen wrote:
 On Sat, Mar 9, 2013 at 6:08 PM, Fredrik Gustafsson iv...@iveqy.com wrote:
  Actually when implemented a str[n]equal_icase that actually should work.
  I break the test suite when trying to replace
  strncmp_icase(pathname, base, baselen)) on line 711 in dir.c and I don't
  get any significant improvements.

 Hmm.. mine passed the test suite.

 Using my patch or your own code? Maybe I just did something wrong. Could
 you see any improvements in speed?

It's the one I posted in [1] and yes it improves speed, numbers in [1].

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

  I like work in this area though, slow commit's are my worst git problem.
  I often have to wait 10s. for a commit to be calculated.

 Personally I don't accept any often used git commands taking more than
 1 second (in hot cache case). What commands do you use? What's the
 size of the repository in terms of tracked/untracked files?

 It's a small repository, 100 MB. However I have a slow hdd which is
 almost full. I often add one file and make an one-line change to an
 other file and then do a git commit -a. That will make git to look
 through the whole repo, which isn't in the kernel RAM cache but needs to
 be reed from the hdd.

commit -a does not run exclude (what I'm improving here). It's
probably stat problem. If you already know what files you have
changed, git add path... then commit without -a might help. Or turn
on core.ignorestat (read doc about it first).
-- 
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] connect.c: Tell *PLink to always use ssh protocol

2013-03-09 Thread Sven Strickroth
Am 07.02.2013 00:22 schrieb Jeff King:
 On Wed, Feb 06, 2013 at 10:58:49PM +0100, Sven Strickroth wrote:
 
 Default values for *plink can be set using PuTTY. If a user makes
 telnet the default in PuTTY this breaks ssh clones in git.

 Since git clones of the type user@host:path use ssh, tell *plink
 to use ssh and override PuTTY defaults for the protocol to use.

 Signed-off-by: Sven Strickroth em...@cs-ware.de
 
 Makes sense to me, though I'd expect to see this cc'd to the msysgit
 list (which I'm doing on this response) for comment from people who
 might be more familiar with the area.

The msysgit people have a git-wrapper which already enables this (see
https://github.com/msysgit/msysgit/blob/master/src/git-wrapper/git-wrapper.c#L62).

-- 
Best regards,
 Sven Strickroth
 PGP key id F5A9D4C4 @ any key-server
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[ANNOUNCE] TopGit 0.9

2013-03-09 Thread Robin Green

Hello,

I'm pleased to announce that TopGit 0.9 was released today.

TopGit aims to make handling of large amounts of interdependent topic
branches easier. In fact, it is designed especially for the case where
you maintain a queue of third-party patches on top of another (perhaps
Git-controlled) project and want to easily organize, maintain and 
submit

them - TopGit achieves that by keeping a separate topic branch for each
patch and providing some tools to maintain the branches.

After a long hiatus, TopGit has a new release, a new maintainer (me), 
and

has moved to GitHub:

  https://github.com/greenrd/topgit

(note that patches are still required to be signed off.)

The 0.9 release is tagged and available for download at: 
https://github.com/greenrd/topgit/tags
(Yes, I know GitHub's display of the tag description is terrible, but 
it

shows up fine in git.)

Because it's been 3 years since the last release, there are quite a few
patches since 0.8, but most of them are quite minor changes.

If you are upgrading from the HEAD of the old TopGit repository, all of 
and
only the patches by me, Andrey Borzenkov and Heiko Hund are new 
compared to

that revision.

Patches can be submitted either to me, to this list, or to the GitHub
issue tracker. There is also an IRC channel, #topgit on 
irc.freenode.net.


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


rebase --merge question

2013-03-09 Thread Stijn Souffriau

Hi all,

From help rebase:

--merge
	Use merging strategies to rebase. When the recursive (default) merge 
strategy is used, this allows rebase to be aware of renames on the 
upstream side.


Renames of what? Files I assume. Are there any disadvantages compared to 
the normal rebase? If not, why isn't --merge the default behaviour.


Thanks,

Stijn

--
Stijn Souffriau
Embedded Software Developer - Mind Embedded Software Division

ESSENSIUM nv
Mind - Embedded Software Division
Gaston Geenslaan 9 - B-3001 Leuven
email : stijn.souffr...@essensium.com
Web: www.essensium.com   /   www.mind.be
BE 872 984 063 RPR Leuven
--
To unsubscribe from this list: send the line 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] perf: update documentation of GIT_PERF_REPEAT_COUNT

2013-03-09 Thread Antoine Pelisse
Currently the documentation of GIT_PERF_REPEAT_COUNT says the default is
five while perf-lib.sh uses a value of three as a default.

Update the documentation so that it is consistent with the code.

Signed-off-by: Antoine Pelisse apeli...@gmail.com
---
 t/perf/README |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/perf/README b/t/perf/README
index b2dbad4..c552f56 100644
--- a/t/perf/README
+++ b/t/perf/README
@@ -56,7 +56,7 @@ You can set the following variables (also in your config.mak):
 
 GIT_PERF_REPEAT_COUNT
Number of times a test should be repeated for best-of-N
-   measurements.  Defaults to 5.
+   measurements.  Defaults to 3.
 
 GIT_PERF_MAKE_OPTS
Options to use when automatically building a git tree for
-- 
1.7.9.5

--
To unsubscribe from this list: send the line 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] format-patch: RFC 2047 says multi-octet character may not be split

2013-03-09 Thread Kirill Smelkov
On Sat, Mar 09, 2013 at 07:27:23PM +0400, Kirill Smelkov wrote:
  8 
 From: Kirill Smelkov k...@mns.spb.ru
  split

Sorry for the confusion...

 8 
From: Kirill Smelkov k...@mns.spb.ru

Even though an earlier attempt (bafc478..41dd00bad) cleaned
up RFC 2047 encoding, pretty.c::add_rfc2047() still decides
where to split the output line by going through the input
one byte at a time, and potentially splits a character in
the middle.  A subject line may end up showing like this:

  fö?? bar.   (instead of   föö bar.)

if split incorrectly.

RFC 2047, section 5 (3) explicitly forbids such beaviour

Each 'encoded-word' MUST represent an integral number of
characters.  A multi-octet character may not be split across
adjacent 'encoded- word's.

that means that e.g. for

Subject:  föö bar

encoding

Subject: =?UTF-8?q?=20f=C3=B6=C3=B6?=
 =?UTF-8?q?=20bar?=

is correct, and

Subject: =?UTF-8?q?=20f=C3=B6=C3?=  -- NOTE ö is broken here
 =?UTF-8?q?=B6=20bar?=

is not, because ö character UTF-8 encoding C3 B6 is split here across
adjacent encoded words.

To fix the problem, make the loop grab one _character_ at a time and
determine its output length to see where to break the output line.  Note
that this version only knows about UTF-8, but the logic to grab one
character is abstracted out in mbs_chrlen() function to make it possible
to extend it to other encodings with the help of iconv in the future.

(With help from Junio C Hamano gits...@pobox.com)
Cc: Jan H. Schönherr schn...@cs.tu-berlin.de
Signed-off-by: Kirill Smelkov k...@mns.spb.ru
---
 pretty.c| 34 ++
 t/t4014-format-patch.sh | 27 ++-
 utf8.c  | 39 +++
 utf8.h  |  2 ++
 4 files changed, 77 insertions(+), 25 deletions(-)

diff --git a/pretty.c b/pretty.c
index b57adef..41f04e6 100644
--- a/pretty.c
+++ b/pretty.c
@@ -345,7 +345,7 @@ static int needs_rfc2047_encoding(const char *line, int len,
return 0;
 }
 
-static void add_rfc2047(struct strbuf *sb, const char *line, int len,
+static void add_rfc2047(struct strbuf *sb, const char *line, size_t len,
   const char *encoding, enum rfc2047_type type)
 {
static const int max_encoded_length = 76; /* per rfc2047 */
@@ -355,9 +355,22 @@ static void add_rfc2047(struct strbuf *sb, const char 
*line, int len,
strbuf_grow(sb, len * 3 + strlen(encoding) + 100);
strbuf_addf(sb, =?%s?q?, encoding);
line_len += strlen(encoding) + 5; /* 5 for =??q? */
-   for (i = 0; i  len; i++) {
-   unsigned ch = line[i]  0xFF;
-   int is_special = is_rfc2047_special(ch, type);
+
+   while (len) {
+   /*
+* RFC 2047, section 5 (3):
+*
+* Each 'encoded-word' MUST represent an integral number of
+* characters.  A multi-octet character may not be split across
+* adjacent 'encoded- word's.
+*/
+   const unsigned char *p = (const unsigned char *)line;
+   int chrlen = mbs_chrlen(line, len, encoding);
+   int is_special = (chrlen  1) || is_rfc2047_special(*p, type);
+
+   /* =%02X * chrlen, or the byte itself */
+   const char *encoded_fmt = is_special ? =%02X: %c;
+   int encoded_len = is_special ? 3 * chrlen : 1;
 
/*
 * According to RFC 2047, we could encode the special character
@@ -367,18 +380,15 @@ static void add_rfc2047(struct strbuf *sb, const char 
*line, int len,
 * causes ' ' to be encoded as '=20', avoiding this problem.
 */
 
-   if (line_len + 2 + (is_special ? 3 : 1)  max_encoded_length) {
+   if (line_len + encoded_len + 2  max_encoded_length) {
+   /* It won't fit with trailing ?= --- break the line */
strbuf_addf(sb, ?=\n =?%s?q?, encoding);
line_len = strlen(encoding) + 5 + 1; /* =??q? plus SP */
}
 
-   if (is_special) {
-   strbuf_addf(sb, =%02X, ch);
-   line_len += 3;
-   } else {
-   strbuf_addch(sb, ch);
-   line_len++;
-   }
+   for (i = 0; i  chrlen; i++)
+   strbuf_addf(sb, encoded_fmt, p[i]);
+   line_len += encoded_len;
}
strbuf_addstr(sb, ?=);
 }
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 78633cb..b993dae 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -837,25 +837,26 @@ Subject: [PATCH] 
=?UTF-8?q?f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f?=
  =?UTF-8?q?=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar?=
  

Re: Merging submodules - best merge-base

2013-03-09 Thread Jens Lehmann
Am 07.03.2013 19:59, schrieb Heiko Voigt:
 On Thu, Mar 07, 2013 at 10:49:09AM +0100, Daniel Bratell wrote:
 Den 2013-03-06 19:12:05 skrev Heiko Voigt hvo...@hvoigt.net:

 On Mon, Feb 25, 2013 at 05:44:05PM +0100, Daniel Bratell wrote:
 A submodule change can be merged, but only if the merge is a
 fast-forward which I think is a fair demand, but currently it
 checks if
 it's a fast-forward from a commit that might not be very interesting
 anymore.

 If two branches A and B split at a point when they used submodule commit
 S1 (based on S), and both then switched to S2 (also based on S)
 and B then
 switched to S21, then it's today not possible to merge B into A, despite
 S21 being a descendant of S2 and you get a conflict and this warning:

 warning: Failed to merge submodule S (commits don't follow merge-base)

 (attempt at ASCII gfx:

 Submodule tree:

 S  S1
   \
\ - S2 -- S21

 Main tree:

 A' (uses S1) --- A (uses S2)
   \
\ --- B' (uses S2) -- B (uses S21)


 I would like it to end up as:

 A' (uses S1) --- A (uses S2)  A+ (uses S21)
   \ /
\ --- B' (uses S2) -- B (uses S21)- /

 And that should be legal since S21 is a descendant of S2.

 So to summarize what you are requesting: You want a submodule merge be
 two way in the view of the superproject and calculate the merge base
 in the submodule from the two commits that are going to be merged?

 It currently sounds logical but I have to think about it further and
 whether that might break other use cases.

 Maybe both could be legal even. The current code can't be all wrong,
 and this case also seems to be straightforward.
 
 Ok I have thought about it further and I did not come up with a simple
 (and stable) enough strategy that would allow your use case to merge
 cleanly without user interaction.
 
 The problem is that your are actually doing a rewind from base to both
 tips. The fact that a rewind is there makes git suspicious and we simply
 give up. IMO, thats the right thing to do in such a situation.
 
 What should a merge strategy do? It infers from two changes what the
 final intention might be. For submodules we can do that when the changes
 on both sides point forward. Since thats the typical progress of
 development. If not there is some reason for it we do not know about. So
 the merge gives up.
 
 Please see this post about why we need to forbid rewinds from the
 initial design discussion:
 
 http://article.gmane.org/gmane.comp.version-control.git/149003

I agree that rewinds are a very good reason not merge two branches using
a fast-forward strategy, but I believe Daniel's use case is a (and maybe
the only) valid exception to that rule: both branches contain *exactly*
the same rewind. In that case I don't see any problem to just do a fast
forward to S21, as both agree on the commits to rewind.
--
To unsubscribe from this list: send the line 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/RFC] Changing submodule foreach --recursive to be depth-first, --parent option to execute command in supermodule as well

2013-03-09 Thread Jens Lehmann
Am 05.03.2013 22:17, schrieb Phil Hord:
 On Tue, Mar 5, 2013 at 3:51 PM, Jens Lehmann jens.lehm...@web.de wrote:
 Am 05.03.2013 19:34, schrieb Junio C Hamano:
 Eric Cousineau eacousin...@gmail.com writes:
 ...
 I am not entirely convinced we would want --include-super in the
 first place, though.  It does not belong to submodule foreach;
 it is doing something _outside_ the submoudules.

 I totally agree with that. First, adding --include-super does not
 belong into the --post-order patch at all, as that is a different
 topic (even though it belongs to the same use case Eric has). Also
 the reason why we are thinking about adding the --post-order option
 IMO cuts the other way for --include-super: It is so easy to do
 that yourself I'm not convinced we should add an extra option to
 foreach for that, especially as it has nothing to do with submodules.
 So I think we should just drop --include-super.
 
 I agree it should not be part of this commit, but I've often found
 myself in need of an --include-super switch.   To me,
 git-submodule-foreach means visit all my .git repos in this project
 and execute $cmd.  It's a pity that the super-project is considered a
 second-class citizen in this regard.

Hmm, for me the super-project is a very natural second-class citizen
to git *submodule* foreach. But also I understand that sometimes the
user wants to apply a command to superproject and submodules alike (I
just recently did exactly that with git gc on our build server).

 I have to do this sometimes:
 
${cmd}  git submodule foreach --recursive '${cmd}'
 
 I often forget the first part in scripts, though, and I've seen others
 do it too.  I usually create a function for it in git-heavy scripts.
 
 In a shell, it usually goes like this:
 
git submodule foreach --recursive '${cmd}'
uphomedel{30-ish}endbackspaceenter
 
 It'd be easier if I could just include a switch for this, and maybe
 even create an alias for it.  But maybe this is different command
 altogether.

Are you sure you wouldn't forget to provide such a switch too? ;-)

I'm still not convinced we should add a new switch, as it can easily
be achieved by adding ${cmd}  to your scripts. And on the command
line you could use an alias like this one to achieve that:

[alias]
recurse = !sh -c \$@  git submodule foreach --recursive $@\
--
To unsubscribe from this list: send the line 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: rebase: strange failures to apply patc 3-way

2013-03-09 Thread Andrew Wong
On 03/09/13 13:32, Andrew Wong wrote:
 Yea, that's really suspicious. This could mean there's an issue with
 when git is checking the index. Try running these a couple times in a
 clean work tree:
 $ git update-index --refresh
 $ git diff-files

 In a clean work tree, these commands should print nothing. But in your
 case, these might print random files that git thinks have been modified...
Before you run those commands each time, you probably have to touch
couple files to trigger the issue:
$ touch file1 file2

Maybe use touch on the files that git rebase has been reporting error?
--
To unsubscribe from this list: send the line 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/19] git-subtree updates

2013-03-09 Thread Paul Campbell
The following set of commits are taken from the collection collated by
Herman van Rink and offered to the list in May of last year
($gmane/196667).

Where updating a commit to resolve a conflict has cleared the original
author of the commit I've noted the original author in the commit
message. Thus I've left the From lines in the format-patch output as
none of the work here is mine and I don't want to assume another's
credit.

I have tried to leave the commit's in a state as close to their
original, with only enough modification to allow them to be applied to
the current HEAD of master.

The git-subtree tests work (make test), but they don't cover any of
the new commands added nor the use of the .gittrees file for storing
the subtree metadata.

They provide the following:

In git-subtree.sh:

* OPTS_SPEC
  * pull/push: options for repository and refspec are both optional,
[repository [refspec]]
  * new sub-command: pull-all
  * new sub-command: push-all
  * new sub-command: list
  * new sub-command: from-submodule
  * new sub-command: prune
  * new sub-command: diff
  * new option for push: --force
* Trailing slash on prefix is removed
* Stores subtree metadata in .gittrees as:
  [subtree $dir]
url = $repository
path = $dir
branch = $refspec
* Replaces a non-visible carriage return character with a properly escaped one
* pull and push: reads options from .gitrees if not provided on the command line
* Implementation of diff
  Fetches remote repo as a temporary git-remote then uses
git-diff-tree to compare before removing the temporary git-remote
* Implementation of list as plain wrapper to new functions subtree_list
  Iterates over subtrees listed in .gittrees and prints out their details
* Implementation of from-submodule
  Converts a git-submodule into a git-subtree
* Implementation of prune
  Removes entries from .gittrees where the $dir is missing
* Implementation of pull-all
  Performs a git-subtree pull for each subtree
* Implementation of push-all
  Performs a git-subtree push for each subtree

In git-subtree.txt:

* Adds brief descriptions for commands:
  * pull-all
  * push-all
  * list
  * from-submodule
  * prune
  * diff (TO BE DOCUMENTED)
* Notes optional -f|--force for push sub-command
* fixes a typo in text for Example 1 (s/incldued/included/)

-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line 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 01/19] spell checking

2013-03-09 Thread Paul Campbell
From 72fc84b6e5085b328cc90e664c9f85a1f5cde36c Mon Sep 17 00:00:00 2001
From: Paul Cartwright paul.cartwri...@ziilabs.com
Date: Thu, 27 Jan 2011 22:33:06 +0800
Subject: [PATCH 01/19] spell checking

---
 contrib/subtree/git-subtree.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt
index 7ba853e..e0957ee 100644
--- a/contrib/subtree/git-subtree.txt
+++ b/contrib/subtree/git-subtree.txt
@@ -270,7 +270,7 @@ git-extensions repository in ~/git-extensions/:
 name

 You can omit the --squash flag, but doing so will increase the number
-of commits that are incldued in your local repository.
+of commits that are included in your local repository.

 We now have a ~/git-extensions/git-subtree directory containing code
 from the master branch of git://github.com/apenwarr/git-subtree.git
-- 
1.8.2.rc1


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


[PATCH 02/19] Add from-submodule. Conflicts: .gitignore contrib/subtree/git-subtree.sh test.sh

2013-03-09 Thread Paul Campbell
From 718c99d167255b28830b6f684d6e6e184fba0f7c Mon Sep 17 00:00:00 2001
From: Paul Campbell pcampb...@kemitix.net
Date: Sat, 9 Mar 2013 18:30:20 +
Subject: [PATCH 02/19] Add from-submodule. Conflicts:   .gitignore
 contrib/subtree/git-subtree.sh test.sh

Original-Author: Peter Jaros pja...@pivotallabs.com
Conflicts-resolved-by: Paul Campbell pcampb...@kemitix.net
---
 contrib/subtree/git-subtree.sh | 30 +-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 8a23f58..caf4988 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -14,6 +14,7 @@ git subtree merge --prefix=prefix commit
 git subtree pull  --prefix=prefix repository refspec...
 git subtree push  --prefix=prefix repository refspec...
 git subtree split --prefix=prefix commit...
+git subtree from-submodule --prefix=prefix
 --
 h,helpshow the help
 q quiet
@@ -101,7 +102,7 @@ done
 command=$1
 shift
 case $command in
-   add|merge|pull) default= ;;
+   add|merge|pull|from-submodule) default= ;;
split|push) default=--default HEAD ;;
*) die Unknown command '$command' ;;
 esac
@@ -721,4 +722,31 @@ cmd_push()
fi
 }

+cmd_from-submodule()
+{
+   ensure_clean
+
+   local submodule_sha=$(git submodule status $prefix | cut -d ' ' -f 2)
+
+   # Remove references to submodule.
+   git config --remove-section submodule.$prefix
+   git config --file .gitmodules --remove-section submodule.$prefix
+   git add .gitmodules
+
+   # Move submodule aside.
+   local tmp_repo=$(mktemp -d /tmp/git-subtree.X)
+   rm -r $tmp_repo
+   mv $prefix $tmp_repo
+   git rm $prefix
+
+   # Commit changes.
+   git commit -m Remove '$prefix/' submodule
+
+   # subtree add from submodule repo.
+   cmd_add_repository $tmp_repo HEAD
+
+   # Remove submodule repo.
+   rm -rf $tmp_repo
+}
+
 cmd_$command $@
-- 
1.8.2.rc1


-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line 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/3] mergetools/p4merge: swap LOCAL and REMOTE

2013-03-09 Thread Kevin Bracey
Reverse LOCAL and REMOTE when invoking P4Merge as a mergetool, so that
the incoming branch is now in the left-hand, blue triangle pane, and the
current branch is in the right-hand, green circle pane.

This change makes use of P4Merge consistent with its built-in help, its
reference documentation, and Perforce itself. But most importantly, it
makes merge results clearer. P4Merge is not totally symmetrical between
left and right; despite changing a few text labels from theirs/ours to
left/right when invoked manually, it still retains its original
Perforce theirs/ours viewpoint.

Most obviously, in the result pane P4Merge shows changes that are common
to both branches in green. This is on the basis of the current branch
being green, as it is when invoked from Perforce; it means that lines in
the result are blue if and only if they are being changed by the merge,
making the resulting diff clearer.

Note that P4Merge now shows ours on the right for both diff and merge,
unlike other diff/mergetools, which always have REMOTE on the right.
But observe that REMOTE is the working tree (ie ours) for a diff,
while it's another branch (ie theirs) for a merge.

Ours and theirs are reversed for a rebase - see git help rebase.
However, this does produce the desired show the results of this commit
effect in P4Merge - changes that remain in the rebased commit (in your
branch, but not in the new base) appear in blue; changes that do not
appear in the rebased commit (from the new base, or common to both) are
in green. If Perforce had rebase, they'd probably not swap ours/theirs,
but make P4Merge show common changes in blue, picking out our changes in
green. We can't do that, so this is next best.

Signed-off-by: Kevin Bracey ke...@bracey.fi
---
 mergetools/p4merge | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mergetools/p4merge b/mergetools/p4merge
index 8a36916..46b3a5a 100644
--- a/mergetools/p4merge
+++ b/mergetools/p4merge
@@ -22,7 +22,7 @@ diff_cmd () {
 merge_cmd () {
touch $BACKUP
$base_present || $BASE
-   $merge_tool_path $BASE $LOCAL $REMOTE $MERGED
+   $merge_tool_path $BASE $REMOTE $LOCAL $MERGED
check_unchanged
 }
 
-- 
1.8.2.rc3.7.g77aeedb

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


[PATCH 03/19] Use .gittrees config file like a .gitmodules when pull or push

2013-03-09 Thread Paul Campbell
From 92787322c6e0e8c9166f02f98a71b6e0af9dc405 Mon Sep 17 00:00:00 2001
From: bibendi bibe...@bk.ru
Date: Fri, 20 May 2011 00:15:53 +0600
Subject: [PATCH 03/19] Use .gittrees config file like a .gitmodules when pull
 or push

---
 contrib/subtree/git-subtree.sh | 31 +--
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index caf4988..cb9e288 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -593,7 +593,8 @@ cmd_split()
eval $grl |
while read rev parents; do
revcount=$(($revcount + 1))
-   say -n $revcount/$revmax ($createcount)

+   say -n $revcount/$revmax ($createcount)
+
debug Processing commit: $rev
exists=$(cache_get $rev)
if [ -n $exists ]; then
@@ -700,21 +701,31 @@ cmd_merge()

 cmd_pull()
 {
-   ensure_clean
-   git fetch $@ || exit $?
-   revs=FETCH_HEAD
-   set -- $revs
-   cmd_merge $@
+if [ $# -ne 1 ]; then
+   die You must provide branch
+   fi
+   if [ -e $dir ]; then
+   ensure_clean
+   repository=$(git config -f .gittrees subtree.$prefix.url)
+   refspec=$1
+   git fetch $repository $refspec || exit $?
+   echo git fetch using:  $repository $refspec
+   revs=FETCH_HEAD
+   set -- $revs
+   cmd_merge $@
+   else
+   die '$dir' must already exist. Try 'git subtree add'.
+   fi
 }

 cmd_push()
 {
-   if [ $# -ne 2 ]; then
-   die You must provide repository refspec
+   if [ $# -ne 1 ]; then
+   die You must provide branch
fi
if [ -e $dir ]; then
-   repository=$1
-   refspec=$2
+   repository=$(git config -f .gittrees subtree.$prefix.url)
+   refspec=$1
echo git push using:  $repository $refspec
git push $repository $(git subtree split
--prefix=$prefix):refs/heads/$refspec
else
-- 
1.8.2.rc1


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


[PATCH 04/19] new commands: pull_all and push_all

2013-03-09 Thread Paul Campbell
From 7e20edee694cbcbac79be4fbe37d9cedebe3e4ee Mon Sep 17 00:00:00 2001
From: Paul Campbell pcampb...@kemitix.net
Date: Sat, 9 Mar 2013 18:31:37 +
Subject: [PATCH 04/19] new commands: pull_all and push_all

Conflicts:
contrib/subtree/git-subtree.sh

Original-Author: bibendi bibe...@bk.ru
Conflicts-resolved-by: Paul Campbell pcampb...@kemitix.net
---
 contrib/subtree/git-subtree.sh | 25 ++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index cb9e288..c3b1208 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -12,6 +12,7 @@ git subtree add   --prefix=prefix commit
 git subtree add   --prefix=prefix repository commit
 git subtree merge --prefix=prefix commit
 git subtree pull  --prefix=prefix repository refspec...
+git subtree pull_all
 git subtree push  --prefix=prefix repository refspec...
 git subtree split --prefix=prefix commit...
 git subtree from-submodule --prefix=prefix
@@ -102,16 +103,18 @@ done
 command=$1
 shift
 case $command in
-   add|merge|pull|from-submodule) default= ;;
+   add|merge|pull|from-submodule|pull_all|push_all) default= ;;
split|push) default=--default HEAD ;;
*) die Unknown command '$command' ;;
 esac

-if [ -z $prefix ]; then
+if [ -z $prefix -a $command != pull_all -a $command !=
push_all ]; then
die You must provide the --prefix option.
 fi

 case $command in
+pull_all);;
+push_all);;
add) [ -e $prefix ] 
die prefix '$prefix' already exists. ;;
*)   [ -e $prefix ] ||
@@ -120,7 +123,7 @@ esac

 dir=$(dirname $prefix/.)

-if [ $command != pull -a $command != add -a $command !=
push ]; then
+if [ $command != pull -a $command != add -a $command !=
push -a $command != pull_all ]; then
revs=$(git rev-parse $default --revs-only $@) || exit $?
dirs=$(git rev-parse --no-revs --no-flags $@) || exit $?
if [ -n $dirs ]; then
@@ -760,4 +763,20 @@ cmd_from-submodule()
rm -rf $tmp_repo
 }

+cmd_pull_all()
+{
+git config -f .gittrees -l | grep subtree | grep path | grep -o
'=.*' | grep -o '[^=].*' |
+while read path; do
+git subtree pull -P $path master || exit $?
+done
+}
+
+cmd_push_all()
+{
+git config -f .gittrees -l | grep subtree | grep path | grep -o
'=.*' | grep -o '[^=].*' |
+while read path; do
+git subtree push -P $path master || exit $?
+done
+}
+
 cmd_$command $@
-- 
1.8.2.rc1


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


[PATCH 05/19] A number of changes to push_all and pull_all:

2013-03-09 Thread Paul Campbell
From 10f2260165d6be3a6ab477ed38fd8ab0308c11e6 Mon Sep 17 00:00:00 2001
From: Paul Campbell pcampb...@kemitix.net
Date: Sat, 9 Mar 2013 18:31:59 +
Subject: [PATCH 05/19] A number of changes to push_all and pull_all:

* adding commands in add to populate the .gittrees file
* changing underscores to dashes (push_all - push-all)
* changing commands to not be hardcoded to branch master from remote
* letting the user specify 0, 1, or 2 arguments to push and pull, like
normal git push and git pull.  We'll try to look up missing
information from .gittrees, like git normally does from .git/config

Conflicts:
.gitignore
contrib/subtree/git-subtree.sh

Original-Author: mhoffman matt.hoff...@quantumretail.com
Conflicts-resolved-by: Paul Campbell pcampb...@kemitix.net
---
 contrib/subtree/git-subtree.sh | 57 ++
 1 file changed, 41 insertions(+), 16 deletions(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index c3b1208..74e4c74 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -12,7 +12,8 @@ git subtree add   --prefix=prefix commit
 git subtree add   --prefix=prefix repository commit
 git subtree merge --prefix=prefix commit
 git subtree pull  --prefix=prefix repository refspec...
-git subtree pull_all
+git subtree pull-all
+git subtree push-all
 git subtree push  --prefix=prefix repository refspec...
 git subtree split --prefix=prefix commit...
 git subtree from-submodule --prefix=prefix
@@ -103,18 +104,18 @@ done
 command=$1
 shift
 case $command in
-   add|merge|pull|from-submodule|pull_all|push_all) default= ;;
+   add|merge|pull|from-submodule|pull-all|push-all) default= ;;
split|push) default=--default HEAD ;;
*) die Unknown command '$command' ;;
 esac

-if [ -z $prefix -a $command != pull_all -a $command !=
push_all ]; then
+if [ -z $prefix -a $command != pull-all -a $command !=
push-all ]; then
die You must provide the --prefix option.
 fi

 case $command in
-pull_all);;
-push_all);;
+pull-all);;
+push-all);;
add) [ -e $prefix ] 
die prefix '$prefix' already exists. ;;
*)   [ -e $prefix ] ||
@@ -123,7 +124,7 @@ esac

 dir=$(dirname $prefix/.)

-if [ $command != pull -a $command != add -a $command !=
push -a $command != pull_all ]; then
+if [ $command != pull -a $command != add -a $command !=
push -a $command != pull-all ]; then
revs=$(git rev-parse $default --revs-only $@) || exit $?
dirs=$(git rev-parse --no-revs --no-flags $@) || exit $?
if [ -n $dirs ]; then
@@ -531,6 +532,14 @@ cmd_add_repository()
revs=FETCH_HEAD
set -- $revs
cmd_add_commit $@
+
+  # now add it to our list of repos
+  git config -f .gittrees --unset subtree.$dir.url
+  git config -f .gittrees --add subtree.$dir.url $repository
+  git config -f .gittrees --unset subtree.$dir.path
+  git config -f .gittrees --add subtree.$dir.path $dir
+  git config -f .gittrees --unset subtree.$dir.branch
+  git config -f .gittrees --add subtree.$dir.branch $refspec
 }

 cmd_add_commit()
@@ -704,13 +713,21 @@ cmd_merge()

 cmd_pull()
 {
-if [ $# -ne 1 ]; then
-   die You must provide branch
+  if [ $# -gt 2 ]; then
+   die You should provide either refspec or repository refspec
fi
if [ -e $dir ]; then
ensure_clean
-   repository=$(git config -f .gittrees subtree.$prefix.url)
-   refspec=$1
+  if [ $# -eq 1 ]; then
+ repository=$(git config -f .gittrees subtree.$prefix.url)
+ refspec=$1
+  elif [ $# -eq 2 ]; then
+repository=$1
+refspec=$2
+  else
+ repository=$(git config -f .gittrees subtree.$prefix.url)
+refspec=$(git config -f .gittrees subtree.$prefix.branch)
+  fi
git fetch $repository $refspec || exit $?
echo git fetch using:  $repository $refspec
revs=FETCH_HEAD
@@ -723,12 +740,20 @@ cmd_pull()

 cmd_push()
 {
-   if [ $# -ne 1 ]; then
-   die You must provide branch
+   if [ $# -gt 2 ]; then
+   die You shold provide either refspec or repository refspec
fi
if [ -e $dir ]; then
-   repository=$(git config -f .gittrees subtree.$prefix.url)
-   refspec=$1
+  if [ $# -eq 1 ]; then
+ repository=$(git config -f .gittrees subtree.$prefix.url)
+refspec=$1
+  elif [ $# -eq 2 ]; then
+repository=$1
+refspec=$2
+  else
+ repository=$(git config -f .gittrees subtree.$prefix.url)
+refspec=$(git config -f .gittrees subtree.$prefix.branch)
+  fi
echo git push using:  $repository $refspec
git push $repository $(git subtree split
--prefix=$prefix):refs/heads/$refspec
else
@@ -763,7 +788,7 @@ cmd_from-submodule()
rm -rf $tmp_repo
 }

-cmd_pull_all()
+cmd_pull-all()
 {
 git 

[PATCH 06/19] merging change from nresni

2013-03-09 Thread Paul Campbell
From b6c810480547966c73bcaaea4c069fe73dacbc05 Mon Sep 17 00:00:00 2001
From: Paul Campbell pcampb...@kemitix.net
Date: Sat, 9 Mar 2013 18:32:24 +
Subject: [PATCH 06/19] merging change from nresni

manual merge at the moment...i'll try a proper merge next now that
formatting is cleaner

Conflicts:
git-subtree.sh

Fixes hidden carriage return

Original-Author: mhoffman matt.hoff...@quantumretail.com
Conflicts-resolved-by: Paul Campbell pcampb...@kemitix.net
---
 contrib/subtree/git-subtree.sh | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 74e4c74..8056851 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -605,8 +605,7 @@ cmd_split()
eval $grl |
while read rev parents; do
revcount=$(($revcount + 1))
-   say -n $revcount/$revmax ($createcount)
-
+   say -ne $revcount/$revmax ($createcount)\r
debug Processing commit: $rev
exists=$(cache_get $rev)
if [ -n $exists ]; then
-- 
1.8.2.rc1


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


[PATCH 07/19] Added check to ensure that split succeeds before trying to push

2013-03-09 Thread Paul Campbell
From ef4d4081474bd9925b60c2ab856260d9174220b9 Mon Sep 17 00:00:00 2001
From: mhart mich...@adslot.com
Date: Sun, 16 Oct 2011 00:16:53 +1100
Subject: [PATCH 07/19] Added check to ensure that split succeeds before trying
 to push

---
 contrib/subtree/git-subtree.sh | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 8056851..ae9f87f 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -754,7 +754,12 @@ cmd_push()
 refspec=$(git config -f .gittrees subtree.$prefix.branch)
   fi
echo git push using:  $repository $refspec
-   git push $repository $(git subtree split
--prefix=$prefix):refs/heads/$refspec
+   rev=$(git subtree split --prefix=$prefix)
+   if [ -n $rev ]; then
+   git push $repository $rev:refs/heads/$refspec
+   else
+   die Couldn't push, 'git subtree split' failed.
+   fi
else
die '$dir' must already exist. Try 'git subtree add'.
fi
-- 
1.8.2.rc1

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


[PATCH 08/19] fixing typo

2013-03-09 Thread Paul Campbell
From 8f6eb2ddfcaef888dc3d3ea4d089aa2e9cad5d0f Mon Sep 17 00:00:00 2001
From: Paul Campbell pcampb...@kemitix.net
Date: Sat, 9 Mar 2013 18:32:53 +
Subject: [PATCH 08/19] fixing typo

Conflicts:
git-subtree.sh

Add diff command

Original-Author: mhoffman matt.hoff...@quantumretail.com
Conflicts-resolved-by: Paul Campbell pcampb...@kemitix.net
---
 contrib/subtree/git-subtree.sh | 34 +-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index ae9f87f..4c3f3c0 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -16,6 +16,7 @@ git subtree pull-all
 git subtree push-all
 git subtree push  --prefix=prefix repository refspec...
 git subtree split --prefix=prefix commit...
+git subtree diff  --prefix=prefix [repository [refspec...]]
 git subtree from-submodule --prefix=prefix
 --
 h,helpshow the help
@@ -105,8 +106,8 @@ command=$1
 shift
 case $command in
add|merge|pull|from-submodule|pull-all|push-all) default= ;;
-   split|push) default=--default HEAD ;;
*) die Unknown command '$command' ;;
+split|push|diff) default=--default HEAD ;;
 esac

 if [ -z $prefix -a $command != pull-all -a $command !=
push-all ]; then
@@ -737,6 +738,37 @@ cmd_pull()
fi
 }

+cmd_diff()
+{
+if [ -e $dir ]; then
+if [ $# -eq 1 ]; then
+repository=$(git config -f .gittrees subtree.$prefix.url)
+refspec=$1
+elif [ $# -eq 2 ]; then
+repository=$1
+refspec=$2
+else
+repository=$(git config -f .gittrees subtree.$prefix.url)
+refspec=$(git config -f .gittrees subtree.$prefix.branch)
+fi
+# this is ugly, but I don't know of a better way to do it. My
git-fu is weak.
+# git diff-tree expects a treeish, but I have only a
repository and branch name.
+# I don't know how to turn that into a treeish without
creating a remote.
+# Please change this if you know a better way!
+tmp_remote=__diff-tmp
+git remote rm $tmp_remote  /dev/null 21
+git remote add -t $refspec $tmp_remote $repository  /dev/null
+# we fetch as a separate step so we can pass -q (quiet),
which isn't an option for git remote
+# could this instead be git fetch -q $repository $refspec
and leave aside creating the remote?
+# Still need a treeish for the diff-tree command...
+git fetch -q $tmp_remote
+git diff-tree -p refs/remotes/$tmp_remote/$refspec
+git remote rm $tmp_remote  /dev/null 21
+else
+die Cannot resolve directory '$dir'. Please point to an
existing subtree directory to diff. Try 'git subtree add' to add a
subtree.
+fi
+}
+
 cmd_push()
 {
if [ $# -gt 2 ]; then
-- 
1.8.2.rc1


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


[PATCH 09/19] Adding a list command

2013-03-09 Thread Paul Campbell
From ca1c855c032d88159ed878f68ef2e18640bbd49c Mon Sep 17 00:00:00 2001
From: Paul Campbell pcampb...@kemitix.net
Date: Sat, 9 Mar 2013 18:33:12 +
Subject: [PATCH 09/19] Adding a list command

Conflicts:
git-subtree.sh

Original-Author: mhoffman matt.hoff...@quantumretail.com
Conflicts-resolved-by: Paul Campbell pcampb...@kemitix.net
---
 contrib/subtree/git-subtree.sh | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 4c3f3c0..7d08064 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -107,10 +107,10 @@ shift
 case $command in
add|merge|pull|from-submodule|pull-all|push-all) default= ;;
*) die Unknown command '$command' ;;
-split|push|diff) default=--default HEAD ;;
+split|push|diff|list) default=--default HEAD ;;
 esac

-if [ -z $prefix -a $command != pull-all -a $command !=
push-all ]; then
+if [ -z $prefix -a $command != pull-all -a $command !=
push-all -a $command != list ]; then
die You must provide the --prefix option.
 fi

@@ -824,6 +824,21 @@ cmd_from-submodule()
rm -rf $tmp_repo
 }

+subtree_list()
+{
+git config -f .gittrees -l | grep subtree | grep path | grep -o
'=.*' | grep -o '[^=].*' |
+while read path; do
+repository=$(git config -f .gittrees subtree.$path.url)
+refspec=$(git config -f .gittrees subtree.$path.branch)
+echo $path(merged from $repository branch $refspec) 
+done
+}
+
+cmd_list()
+{
+  subtree_list
+}
+
 cmd_pull-all()
 {
 git config -f .gittrees -l | grep subtree | grep path | grep -o
'=.*' | grep -o '[^=].*' |
-- 
1.8.2.rc1


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


[PATCH 10/19] 'prune' command to clear out stale .gittrees info

2013-03-09 Thread Paul Campbell
From 1aaa55ff64b3b4d9325568b3bb863748f20c80f3 Mon Sep 17 00:00:00 2001
From: Paul Campbell pcampb...@kemitix.net
Date: Sat, 9 Mar 2013 18:33:33 +
Subject: [PATCH 10/19] 'prune' command to clear out stale .gittrees info

Conflicts:
git-subtree.sh

Original-Author: Nate Jones n...@endot.org
Conflicts-resolved-by: Paul Campbell pcampb...@kemitix.net
---
 contrib/subtree/git-subtree.sh | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 7d08064..0c41383 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -105,12 +105,12 @@ done
 command=$1
 shift
 case $command in
-   add|merge|pull|from-submodule|pull-all|push-all) default= ;;
+add|merge|pull|from-submodule|pull-all|push-all|prune) default= ;;
*) die Unknown command '$command' ;;
 split|push|diff|list) default=--default HEAD ;;
 esac

-if [ -z $prefix -a $command != pull-all -a $command !=
push-all -a $command != list ]; then
+if [ -z $prefix -a $command != pull-all -a $command !=
push-all -a $command != list -a $command != prune ]; then
die You must provide the --prefix option.
 fi

@@ -839,6 +839,17 @@ cmd_list()
   subtree_list
 }

+cmd_prune()
+{
+git config -f .gittrees -l | grep subtree | grep path | grep -o
'=.*' | grep -o '[^=].*' |
+while read path; do
+if [ ! -e $path ]; then
+echo pruning $path
+git config -f .gittrees --remove-section subtree.$path
+fi
+done
+}
+
 cmd_pull-all()
 {
 git config -f .gittrees -l | grep subtree | grep path | grep -o
'=.*' | grep -o '[^=].*' |
-- 
1.8.2.rc1


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


[PATCH 11/19] Add prune command to OPTS_SPEC

2013-03-09 Thread Paul Campbell
From 48e77d62e05582e2aec4c634a913f28f3f804a37 Mon Sep 17 00:00:00 2001
From: Paul Campbell pcampb...@kemitix.net
Date: Sat, 9 Mar 2013 18:33:50 +
Subject: [PATCH 11/19] Add prune command to OPTS_SPEC

Conflicts:
git-subtree.sh

Original-Author: Herman van Rink r...@initfour.nl
Conflicts-resolved-by: Paul Campbell pcampb...@kemitix.net
---
 contrib/subtree/git-subtree.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 0c41383..d67fe5a 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -18,6 +18,7 @@ git subtree push  --prefix=prefix repository refspec...
 git subtree split --prefix=prefix commit...
 git subtree diff  --prefix=prefix [repository [refspec...]]
 git subtree from-submodule --prefix=prefix
+git subtree prune
 --
 h,helpshow the help
 q quiet
-- 
1.8.2.rc1


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


[PATCH 12/19] Remove trailing slash from prefix parameter

2013-03-09 Thread Paul Campbell
From d4aa87f53b61481d2f916415f0baec527a8b6417 Mon Sep 17 00:00:00 2001
From: Paul Campbell pcampb...@kemitix.net
Date: Sat, 9 Mar 2013 18:34:10 +
Subject: [PATCH 12/19] Remove trailing slash from prefix parameter

Conflicts:
git-subtree.sh

Original-Author: Herman van Rink r...@initfour.nl
Conflicts-resolved-by: Paul Campbell pcampb...@kemitix.net
---
 contrib/subtree/git-subtree.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index d67fe5a..ae7d1fe 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -103,6 +103,9 @@ while [ $# -gt 0 ]; do
esac
 done

+# Remove trailing slash
+prefix=${prefix%/};
+
 command=$1
 shift
 case $command in
-- 
1.8.2.rc1


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


[PATCH 14/19] Document pull-all and push-all

2013-03-09 Thread Paul Campbell
From 7dcd40ab8687a588b7b0c6ff914a7cfb601b6774 Mon Sep 17 00:00:00 2001
From: Herman van Rink r...@initfour.nl
Date: Tue, 27 Mar 2012 13:59:16 +0200
Subject: [PATCH 14/19] Document pull-all and push-all

---
 contrib/subtree/git-subtree.txt | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt
index e0957ee..c8fc103 100644
--- a/contrib/subtree/git-subtree.txt
+++ b/contrib/subtree/git-subtree.txt
@@ -92,13 +92,19 @@ pull::
Exactly like 'merge', but parallels 'git pull' in that
it fetches the given commit from the specified remote
repository.
-   
+
+pull-all::
+   Perform a pull operation on all in .gittrees registered subtrees.
+
 push::
Does a 'split' (see below) using the prefix supplied
and then does a 'git push' to push the result to the
repository and refspec. This can be used to push your
subtree to different branches of the remote repository.

+push-all::
+   Perform a pull operation on all in .gittrees registered subtrees.
+
 split::
Extract a new, synthetic project history from the
history of the prefix subtree.  The new history
-- 
1.8.2.rc1


-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line 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/3] git-merge-one-file: revise merge error reporting

2013-03-09 Thread Kevin Bracey
Commit 718135e improved the merge error reporting for the resolve
strategy's merge conflict and permission conflict cases, but led to a
malformed ERROR:  in myfile.c message in the case of a file added
differently.

This commit reverts that change, and uses an alternative approach without
this flaw.

Signed-off-by: Kevin Bracey ke...@bracey.fi
---
 git-merge-one-file.sh | 20 +++-
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/git-merge-one-file.sh b/git-merge-one-file.sh
index 1236fbf..70f36f1 100755
--- a/git-merge-one-file.sh
+++ b/git-merge-one-file.sh
@@ -104,11 +104,13 @@ case ${1:-.}${2:-.}${3:-.} in
;;
esac
 
+   ret=0
src1=$(git-unpack-file $2)
src2=$(git-unpack-file $3)
case $1 in
'')
-   echo Added $4 in both, but differently.
+   echo ERROR: Added $4 in both, but differently.
+   ret=1
orig=$(git-unpack-file $2)
create_virtual_base $orig $src1 $src2
;;
@@ -121,10 +123,9 @@ case ${1:-.}${2:-.}${3:-.} in
# Be careful for funny filename such as -L in $4, which
# would confuse merge greatly.
git merge-file $src1 $orig $src2
-   ret=$?
-   msg=
-   if [ $ret -ne 0 ]; then
-   msg='content conflict'
+   if [ $? -ne 0 ]; then
+   echo ERROR: Content conflict in $4
+   ret=1
fi
 
# Create the working tree file, using our tree version from the
@@ -133,18 +134,11 @@ case ${1:-.}${2:-.}${3:-.} in
rm -f -- $orig $src1 $src2
 
if [ $6 != $7 ]; then
-   if [ -n $msg ]; then
-   msg=$msg, 
-   fi
-   msg=${msg}permissions conflict: $5-$6,$7
-   ret=1
-   fi
-   if [ $1 = '' ]; then
+   echo ERROR: Permissions conflict: $5-$6,$7
ret=1
fi
 
if [ $ret -ne 0 ]; then
-   echo ERROR: $msg in $4
exit 1
fi
exec git update-index -- $4
-- 
1.8.2.rc3.7.g77aeedb

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


[PATCH 15/19] Document from-submodule and prune commands

2013-03-09 Thread Paul Campbell
From 6dc8119a7d99f7107e32f2c5d7ec18b9fd93a6b8 Mon Sep 17 00:00:00 2001
From: Herman van Rink r...@initfour.nl
Date: Tue, 27 Mar 2012 14:14:54 +0200
Subject: [PATCH 15/19] Document from-submodule and prune commands

---
 contrib/subtree/git-subtree.txt | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt
index c8fc103..48ba158 100644
--- a/contrib/subtree/git-subtree.txt
+++ b/contrib/subtree/git-subtree.txt
@@ -129,6 +129,16 @@ split::
Note that if you use '--squash' when you merge, you
should usually not just '--rejoin' when you split.

+from-submodule::
+   Convert a git submodule to a subtree.
+   The module is removed from the .gitmodules file and
+   the repo contents are integrated as a subtree.
+
+prune::
+   Cleanup .gittrees entries for which the subtree nolonger exists.
+
+diff::
+   TO BE DOCUMENTED

 OPTIONS
 ---
-- 
1.8.2.rc1


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


[PATCH 16/19] Update SYNOPSIS

2013-03-09 Thread Paul Campbell
From 6024d877e6c3beebe4c11bd060553d06af422680 Mon Sep 17 00:00:00 2001
From: Paul Campbell pcampb...@kemitix.net
Date: Sat, 9 Mar 2013 18:34:54 +
Subject: [PATCH 16/19] Update SYNOPSIS

Conflicts:
contrib/subtree/git-subtree.txt

Original-Author: Herman van Rink r...@initfour.nl
Conflicts-resolved-by: Paul Campbell pcampb...@kemitix.net
---
 contrib/subtree/git-subtree.txt | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt
index 48ba158..b485ab5 100644
--- a/contrib/subtree/git-subtree.txt
+++ b/contrib/subtree/git-subtree.txt
@@ -9,13 +9,16 @@ git-subtree - Merge subtrees together and split
repository into subtrees
 SYNOPSIS
 
 [verse]
-'git subtree' add   -P prefix refspec
-'git subtree' add   -P prefix repository refspec
-'git subtree' pull  -P prefix repository refspec...
-'git subtree' push  -P prefix repository refspec...
-'git subtree' merge -P prefix commit
-'git subtree' split -P prefix [OPTIONS] [commit]
-
+'git subtree' add   --prefix=prefix repository refspec
+'git subtree' merge --prefix=prefix commit
+'git subtree' pull  --prefix=prefix [repository [refspec...]]
+'git subtree' pull-all
+'git subtree' push-all
+'git subtree' push  --prefix=prefix [repository [refspec...]]
+'git subtree' split --prefix=prefix commit...
+'git subtree' from-submodule --prefix=prefix
+'git subtree' prune
+'git subtree' diff  --prefix=prefix [repository [refspec...]]

 DESCRIPTION
 ---
-- 
1.8.2.rc1


-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line 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 17/19] Document list command

2013-03-09 Thread Paul Campbell
From fed80cb47dffcb805a7808e8574dda44992363b0 Mon Sep 17 00:00:00 2001
From: Paul Campbell pcampb...@kemitix.net
Date: Sat, 9 Mar 2013 18:35:18 +
Subject: [PATCH 17/19] Document list command

Conflicts:
git-subtree.sh

Original-Author: Herman van Rink r...@initfour.nl
Conflicts-resolved-by: Paul Campbell pcampb...@kemitix.net
---
 contrib/subtree/git-subtree.sh  | 1 +
 contrib/subtree/git-subtree.txt | 4 
 2 files changed, 5 insertions(+)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 84c90c7..4605203 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -15,6 +15,7 @@ git subtree pull  --prefix=prefix repository refspec...
 git subtree pull-all
 git subtree push-all
 git subtree push  --prefix=prefix repository refspec...
+git subtree list
 git subtree split --prefix=prefix commit...
 git subtree diff  --prefix=prefix [repository [refspec...]]
 git subtree from-submodule --prefix=prefix
diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt
index b485ab5..385bde8 100644
--- a/contrib/subtree/git-subtree.txt
+++ b/contrib/subtree/git-subtree.txt
@@ -15,6 +15,7 @@ SYNOPSIS
 'git subtree' pull-all
 'git subtree' push-all
 'git subtree' push  --prefix=prefix [repository [refspec...]]
+'git subtree' list
 'git subtree' split --prefix=prefix commit...
 'git subtree' from-submodule --prefix=prefix
 'git subtree' prune
@@ -108,6 +109,9 @@ push::
 push-all::
Perform a pull operation on all in .gittrees registered subtrees.

+list::
+   Show a list of the in .gittrees registered subtrees
+
 split::
Extract a new, synthetic project history from the
history of the prefix subtree.  The new history
-- 
1.8.2.rc1


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


[PATCH 18/19] Added --force option to push

2013-03-09 Thread Paul Campbell
From ae7c05bdc6d02fa89deabb59cec6150308f227f7 Mon Sep 17 00:00:00 2001
From: Paul Campbell pcampb...@kemitix.net
Date: Sat, 9 Mar 2013 18:35:42 +
Subject: [PATCH 18/19] Added --force option to push

Conflicts:
contrib/subtree/git-subtree.sh

Original-Author: James Roper jro...@vz.net
Conflicts-resolved-by: Paul Campbell pcampb...@kemitix.net
---
 contrib/subtree/git-subtree.sh  | 9 -
 contrib/subtree/git-subtree.txt | 5 +
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 4605203..3582a55 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -32,6 +32,8 @@ b,branch= create a new branch from the split subtree
 ignore-joins  ignore prior --rejoin commits
 onto= try connecting new tree to an existing one
 rejoinmerge the new branch back into HEAD
+ options for 'push'
+f,force   use force push
  options for 'add', 'merge', 'pull' and 'push'
 squashmerge subtree changes as a single commit
 
@@ -90,6 +92,7 @@ while [ $# -gt 0 ]; do
-b) branch=$1; shift ;;
-P) prefix=$1; shift ;;
-m) message=$1; shift ;;
+-f|--force) force=1 ;;
--no-prefix) prefix= ;;
--onto) onto=$1; shift ;;
--no-onto) onto= ;;
@@ -790,10 +793,14 @@ cmd_push()
  repository=$(git config -f .gittrees subtree.$prefix.url)
 refspec=$(git config -f .gittrees subtree.$prefix.branch)
   fi
+push_opts=
+if [ $force == 1 ]; then
+push_opts=$push_opts --force
+fi
echo git push using:  $repository $refspec
rev=$(git subtree split --prefix=$prefix)
if [ -n $rev ]; then
-   git push $repository $rev:refs/heads/$refspec
+   git push $push_opts $repository $rev:refs/heads/$refspec
else
die Couldn't push, 'git subtree split' failed.
fi
diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt
index 385bde8..9e9eb9e 100644
--- a/contrib/subtree/git-subtree.txt
+++ b/contrib/subtree/git-subtree.txt
@@ -278,6 +278,11 @@ OPTIONS FOR split
'--rejoin' when you split, because you don't want the
subproject's history to be part of your project anyway.

+OPTIONS FOR push
+
+-f::
+--force::
+Uses 'git push --force'.

 EXAMPLE 1. Add command
 --
-- 
1.8.2.rc1


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


[PATCH 19/19] Fix some trailing whitespace

2013-03-09 Thread Paul Campbell
From 54d376c3d731ce9e528fe9095ea6c16d382b5ce3 Mon Sep 17 00:00:00 2001
From: Paul Campbell pcampb...@kemitix.net
Date: Sat, 9 Mar 2013 18:36:22 +
Subject: [PATCH 19/19] Fix some trailing whitespace

Conflicts:
contrib/subtree/.gitignore
contrib/subtree/git-subtree.sh
contrib/subtree/test.sh

Original-Author: Herman van Rink r...@initfour.nl

OPTS_SPEC for push and pull updated (should have been picked up in an
earlier commit)

Fixed order of cases in setting the --default parameter

Conflicts-resolved-by: Paul Campbell pcampb...@kemitix.net
---
 contrib/subtree/git-subtree.sh | 223 +
 1 file changed, 114 insertions(+), 109 deletions(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 3582a55..df1413d 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -11,10 +11,10 @@ OPTS_SPEC=\
 git subtree add   --prefix=prefix commit
 git subtree add   --prefix=prefix repository commit
 git subtree merge --prefix=prefix commit
-git subtree pull  --prefix=prefix repository refspec...
+git subtree pull  --prefix=prefix [repository [refspec...]]
 git subtree pull-all
 git subtree push-all
-git subtree push  --prefix=prefix repository refspec...
+git subtree push  --prefix=prefix [repository [refspec...]]
 git subtree list
 git subtree split --prefix=prefix commit...
 git subtree diff  --prefix=prefix [repository [refspec...]]
@@ -92,7 +92,7 @@ while [ $# -gt 0 ]; do
-b) branch=$1; shift ;;
-P) prefix=$1; shift ;;
-m) message=$1; shift ;;
--f|--force) force=1 ;;
+   -f|--force) force=1 ;;
--no-prefix) prefix= ;;
--onto) onto=$1; shift ;;
--no-onto) onto= ;;
@@ -113,9 +113,9 @@ prefix=${prefix%/};
 command=$1
 shift
 case $command in
-add|merge|pull|from-submodule|pull-all|push-all|prune) default= ;;
+   add|merge|pull|pull-all|push-all|from-submodule|prune) default= ;;
+   split|push|diff|list) default=--default HEAD ;;
*) die Unknown command '$command' ;;
-split|push|diff|list) default=--default HEAD ;;
 esac

 if [ -z $prefix -a $command != pull-all -a $command !=
push-all -a $command != list -a $command != prune ]; then
@@ -123,8 +123,10 @@ if [ -z $prefix -a $command != pull-all -a
$command != push-all -a $c
 fi

 case $command in
-pull-all);;
-push-all);;
+   pull-all);;
+   push-all);;
+   list);;
+   prune);;
add) [ -e $prefix ] 
die prefix '$prefix' already exists. ;;
*)   [ -e $prefix ] ||
@@ -133,7 +135,7 @@ esac

 dir=$(dirname $prefix/.)

-if [ $command != pull -a $command != add -a $command !=
push -a $command != pull-all ]; then
+if [ $command != pull -a $command != add -a $command !=
push -a $command != pull-all -a $command != diff ]; then
revs=$(git rev-parse $default --revs-only $@) || exit $?
dirs=$(git rev-parse --no-revs --no-flags $@) || exit $?
if [ -n $dirs ]; then
@@ -541,14 +543,14 @@ cmd_add_repository()
revs=FETCH_HEAD
set -- $revs
cmd_add_commit $@
-
-  # now add it to our list of repos
-  git config -f .gittrees --unset subtree.$dir.url
-  git config -f .gittrees --add subtree.$dir.url $repository
-  git config -f .gittrees --unset subtree.$dir.path
-  git config -f .gittrees --add subtree.$dir.path $dir
-  git config -f .gittrees --unset subtree.$dir.branch
-  git config -f .gittrees --add subtree.$dir.branch $refspec
+
+   # now add it to our list of repos
+   git config -f .gittrees --unset subtree.$dir.url
+   git config -f .gittrees --add subtree.$dir.url $repository
+   git config -f .gittrees --unset subtree.$dir.path
+   git config -f .gittrees --add subtree.$dir.path $dir
+   git config -f .gittrees --unset subtree.$dir.branch
+   git config -f .gittrees --add subtree.$dir.branch $refspec
 }

 cmd_add_commit()
@@ -721,89 +723,91 @@ cmd_merge()

 cmd_pull()
 {
-  if [ $# -gt 2 ]; then
-   die You should provide either refspec or repository refspec
+   if [ $# -gt 2 ]; then
+   die You should provide either refspec or repository 
refspec
fi
if [ -e $dir ]; then
-   ensure_clean
-  if [ $# -eq 1 ]; then
- repository=$(git config -f .gittrees subtree.$prefix.url)
- refspec=$1
-  elif [ $# -eq 2 ]; then
-repository=$1
-refspec=$2
-  else
- repository=$(git config -f .gittrees subtree.$prefix.url)
-refspec=$(git config -f .gittrees subtree.$prefix.branch)
-  fi
-   git fetch $repository $refspec || exit $?
-   echo git fetch using:  $repository $refspec
-   revs=FETCH_HEAD
-   set -- $revs
-   cmd_merge $@
+   ensure_clean
+   if [ $# -eq 1 ]; then
+   repository=$(git config -f 

Re: [PATCH 01/19] spell checking

2013-03-09 Thread Junio C Hamano
Paul Campbell pcampb...@kemitix.net writes:

 From 72fc84b6e5085b328cc90e664c9f85a1f5cde36c Mon Sep 17 00:00:00 2001
 From: Paul Cartwright paul.cartwri...@ziilabs.com
 Date: Thu, 27 Jan 2011 22:33:06 +0800
 Subject: [PATCH 01/19] spell checking

 ---
  contrib/subtree/git-subtree.txt | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

I won't repeat these for other 18 patches, but please:

 - drop the first From object name magic timestamp line which
   is not part of the patch (it is only meant to help people who
   maintain the file(1) and magic(5));

 - keep From: author name ... and Date:  lines for other
   peoples' patches you are forwarding (they can be dropped for your
   own patches); and

 - drop Subject:  as that is the same as the subject of the e-mail
   message.

 - fix the subject to make it clear that the change is for
   contrib/subtree.

   spell checking [*1*] in the output of git shortlog v1.8.1..,
   together with other 600+ patches' titles, will not help the
   reader to see how much activity each area had and who worked in
   what area.

 - have the authors sign-off their patches, and then add yours as
   the person who is forwarding other peoples' patches (see
   Documentation/SubmittingPatches).

 - Cc the area maintainer (I thought it was David Greene?)

if these patches are meant to become part of git.git eventually.

Thanks.


[Footnote]

*1* Besides, a patch can never be spell *checking*.  It would be
 typofix after the author did a 'spell checking' ;-)
--
To unsubscribe from this list: send the line 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 01/19] spell checking

2013-03-09 Thread Paul Campbell
On Sat, Mar 9, 2013 at 7:45 PM, Junio C Hamano gits...@pobox.com wrote:
 Paul Campbell pcampb...@kemitix.net writes:

 From 72fc84b6e5085b328cc90e664c9f85a1f5cde36c Mon Sep 17 00:00:00 2001
 From: Paul Cartwright paul.cartwri...@ziilabs.com
 Date: Thu, 27 Jan 2011 22:33:06 +0800
 Subject: [PATCH 01/19] spell checking

 ---
  contrib/subtree/git-subtree.txt | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 I won't repeat these for other 18 patches, but please:

Thanks and apologies. All noted, although I have a question below.

  - drop the first From object name magic timestamp line which
is not part of the patch (it is only meant to help people who
maintain the file(1) and magic(5));

  - keep From: author name ... and Date:  lines for other
peoples' patches you are forwarding (they can be dropped for your
own patches); and

  - drop Subject:  as that is the same as the subject of the e-mail
message.

  - fix the subject to make it clear that the change is for
contrib/subtree.

spell checking [*1*] in the output of git shortlog v1.8.1..,
together with other 600+ patches' titles, will not help the
reader to see how much activity each area had and who worked in
what area.

I'd wanted to avoid changing the original author's work as much as
possible. Wrong choice on my part.

  - have the authors sign-off their patches, and then add yours as
the person who is forwarding other peoples' patches (see
Documentation/SubmittingPatches).

Four of the eight original authors now have dead email addresses. As I
found out when I started getting the mail bounces when I started
sending these patches out. Would it be acceptable for those patches to
leave the From line, add a Based-on-patch-by and then sign of myself?
I've really only done enough on top of the cherry-picking to get round
any conflicts.

  - Cc the area maintainer (I thought it was David Greene?)

 if these patches are meant to become part of git.git eventually.

I knew that and forgot. Can I blame this on my head-cold? No?

 Thanks.


 [Footnote]

 *1* Besides, a patch can never be spell *checking*.  It would be
  typofix after the author did a 'spell checking' ;-)

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


Segfault in git 1.8.1.5

2013-03-09 Thread Strasser Pablo
Hello,

I segfault with the following command:

git checkout HEAD~1
git branch -u origin/master

I think it's because i'm in detached head.
A error message like cannot use this command in would be a better responce 
than a segfault.

Good day.
--
To unsubscribe from this list: send the line 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 01/19] spell checking

2013-03-09 Thread Jonathan Nieder
Paul Campbell wrote:

 Four of the eight original authors now have dead email addresses. As I
 found out when I started getting the mail bounces when I started
 sending these patches out. Would it be acceptable for those patches to
 leave the From line, add a Based-on-patch-by and then sign of myself?

It's always nice to get the original author's sign-off, but if you can
certify what's stated in the DCO1.1 (from
Documentation/SubmittingPatches) then just adding your sign-off is
fine.  Please still keep the original authorship in that case, and no
need to add a Based-on-patch-by line.

Thanks,
Jonathan
--
To unsubscribe from this list: send the line 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/3] Improve P4Merge mergetool invocation

2013-03-09 Thread Kevin Bracey
Incorporated comments on the previous patches, and one new patch
addressing a problem I spotted while testing git-merge-one-file.

I couldn't figure out how to use git diff to achieve the effect of the
external diff here - we'd need some alternative to achieve what it does
with the -L option, and I failed to come up with anything remotely elegant.

Kevin Bracey (3):
  mergetools/p4merge: swap LOCAL and REMOTE
  mergetools/p4merge: create a base if none available
  git-merge-one-file: revise merge error reporting

 git-merge-one-file.sh | 38 --
 git-sh-setup.sh   | 13 +
 mergetools/p4merge|  8 ++--
 3 files changed, 31 insertions(+), 28 deletions(-)

-- 
1.8.2.rc3.7.g77aeedb

--
To unsubscribe from this list: send the line 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: Segfault in git 1.8.1.5

2013-03-09 Thread Dennis Kaarsemaker
On za, 2013-03-09 at 21:16 +0100, Strasser Pablo wrote:
 Hello,
 
 I segfault with the following command:
 
 git checkout HEAD~1
 git branch -u origin/master
 
 I think it's because i'm in detached head.
 A error message like cannot use this command in would be a better responce 
 than a segfault.

Confirmed.

dennis@lightning:/tmp/hacks$ gdb --args ~/code/git/git branch -u origin/master
(gdb) run
Starting program: /home/dennis/code/git/git branch -u origin/master
[Thread debugging using libthread_db enabled]
Using host libthread_db library /lib/i386-linux-gnu/libthread_db.so.1.

Program received signal SIGSEGV, Segmentation fault.
cmd_branch (argc=0, argv=0xbfffec08, prefix=0x0) at builtin/branch.c:886
886 if (!ref_exists(branch-refname))
(gdb) bt
#0  cmd_branch (argc=0, argv=0xbfffec08, prefix=0x0) at builtin/branch.c:886
#1  0x0804c26c in run_builtin (argv=0xbfffec08, argc=3, p=0x819f3f4 
commands.21695+84) at git.c:273
#2  handle_internal_command (argc=3, argv=0xbfffec08) at git.c:435
#3  0x0804b656 in run_argv (argv=0xbfffeb74, argcp=0xbfffeb70) at git.c:481
#4  main (argc=3, argv=0xbfffec08) at git.c:556

But it's already been fixed by 8efb889: branch: segfault fixes and
validation. 
-- 
Dennis Kaarsemaker
www.kaarsemaker.net

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


Re: Segfault in git 1.8.1.5

2013-03-09 Thread Junio C Hamano
Strasser Pablo strasserpa...@bluewin.ch writes:

 I segfault with the following command:

 git checkout HEAD~1
 git branch -u origin/master

A patch to address this in cooking in 'next', and is expected to be
in 1.8.2.1 or later.
--
To unsubscribe from this list: send the line 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: Segfault in git 1.8.1.5

2013-03-09 Thread Strasser Pablo
On Saturday 09 March 2013 13.16:35 Junio C Hamano wrote:
 Strasser Pablo strasserpa...@bluewin.ch writes:
  I segfault with the following command:
  
  git checkout HEAD~1
  git branch -u origin/master
 
 A patch to address this in cooking in 'next', and is expected to be
 in 1.8.2.1 or later.

Ok 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


[PATCH v3 0/2] shell: allow 'no-interactive-login' command to disable interactive shell

2013-03-09 Thread Jonathan Nieder
Hi again,

Here's a reroll along the lines described at
http://thread.gmane.org/gmane.comp.version-control.git/216229

As before, this series is meant to give users of basic 'git shell'
setups a chance to imitate some nice behaviors that GitHub and
gitolite offer in more complicated ways.  Thanks for your help on it
so far.

Jonathan Nieder (2):
  shell doc: emphasize purpose and security model
  shell: allow customization of interactive login disabled message

 Documentation/git-shell.txt | 86 +
 shell.c | 13 +++
 2 files changed, 84 insertions(+), 15 deletions(-)
--
To unsubscribe from this list: send the line 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] shell doc: emphasize purpose and security model

2013-03-09 Thread Jonathan Nieder
The original git-shell(1) manpage emphasized that the shell supports
only git transport commands.  As the shell gained features, that
emphasis and focus in the manual has been lost.  Bring it back by
splitting the manpage into a few short sections and fleshing out each:

 - SYNOPSIS, describing how the shell gets used in practice
 - DESCRIPTION, which gives an overview of the purpose and guarantees
   provided by this restricted shell
 - COMMANDS, listing supported commands and restrictions on the
   arguments they accept
 - INTERACTIVE USE, describing the interactive mode

Also add a see also section with related reading.

Signed-off-by: Jonathan Nieder jrnie...@gmail.com
---
Changes since v2:

 - use command -v instead of which in synopsis to subtly reinforce
   good habits
 - use user instead of hardcoding git username in synopsis
 - give up on typesetting git  in monospace, since the toolchain
   doesn't seem to like lonely backticks :/
 - clarify change description

The actual text is pretty much the same.

 Documentation/git-shell.txt | 66 ++---
 1 file changed, 51 insertions(+), 15 deletions(-)

diff --git a/Documentation/git-shell.txt b/Documentation/git-shell.txt
index 9b925060..544b21aa 100644
--- a/Documentation/git-shell.txt
+++ b/Documentation/git-shell.txt
@@ -9,25 +9,61 @@ git-shell - Restricted login shell for Git-only SSH access
 SYNOPSIS
 
 [verse]
-'git shell' [-c command argument]
+'chsh' -s $(command -v git-shell) user
+'git clone' user`@localhost:/path/to/repo.git`
+'ssh' user`@localhost`
 
 DESCRIPTION
 ---
 
-A login shell for SSH accounts to provide restricted Git access. When
-'-c' is given, the program executes command non-interactively;
-command can be one of 'git receive-pack', 'git upload-pack', 'git
-upload-archive', 'cvs server', or a command in COMMAND_DIR. The shell
-is started in interactive mode when no arguments are given; in this
-case, COMMAND_DIR must exist, and any of the executables in it can be
-invoked.
-
-'cvs server' is a special command which executes git-cvsserver.
-
-COMMAND_DIR is the path $HOME/git-shell-commands. The user must have
-read and execute permissions to the directory in order to execute the
-programs in it. The programs are executed with a cwd of $HOME, and
-argument is parsed as a command-line string.
+This is a login shell for SSH accounts to provide restricted Git access.
+It permits execution only of server-side Git commands implementing the
+pull/push functionality, plus custom commands present in a subdirectory
+named `git-shell-commands` in the user's home directory.
+
+COMMANDS
+
+
+'git shell' accepts the following commands after the '-c' option:
+
+'git receive-pack argument'::
+'git upload-pack argument'::
+'git upload-archive argument'::
+   Call the corresponding server-side command to support
+   the client's 'git push', 'git fetch', or 'git archive --remote'
+   request.
+'cvs server'::
+   Imitate a CVS server.  See linkgit:git-cvsserver[1].
+
+If a `~/git-shell-commands` directory is present, 'git shell' will
+also handle other, custom commands by running
+`git-shell-commands/command arguments` from the user's home
+directory.
+
+INTERACTIVE USE
+---
+
+By default, the commands above can be executed only with the '-c'
+option; the shell is not interactive.
+
+If a `~/git-shell-commands` directory is present, 'git shell'
+can also be run interactively (with no arguments).  If a `help`
+command is present in the `git-shell-commands` directory, it is
+run to provide the user with an overview of allowed actions.  Then a
+git  prompt is presented at which one can enter any of the
+commands from the `git-shell-commands` directory, or `exit` to close
+the connection.
+
+Generally this mode is used as an administrative interface to allow
+users to list repositories they have access to, create, delete, or
+rename repositories, or change repository descriptions and
+permissions.
+
+SEE ALSO
+
+ssh(1),
+linkgit:git-daemon[1],
+contrib/git-shell-commands/README
 
 GIT
 ---
-- 
1.8.2.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


[PATCH 2/2] shell: new no-interactive-login command to print a custom message

2013-03-09 Thread Jonathan Nieder
If I disable git-shell's interactive mode by removing the
~/git-shell-commands directory, attempts to use 'ssh' in produce a
message intended for the administrator:

$ ssh git@myserver
fatal: Interactive git shell is not enabled.
hint: ~/git-shell-commands should exist and have read and execute 
access.
$

That is helpful for the new admin who is wondering What? Why isn't
the git-shell I just set up working?, but once the site setup is
complete, it would be better to give the user a friendly hint that she
is on the right track, like GitHub does.

Hi username! You've successfully authenticated, but
GitHub does not provide shell access.

An appropriate greeting might even include more complex dynamic
information, like gitolite's list of repositories the user has access
to.  Add support for a ~/git-shell-commands/no-interactive-login
command that generates an arbitrary greeting.  When the user tries to
log in:

 * If the file ~/git-shell-commands/no-interactive-login exists,
   run no-interactive-login to let the server say what it likes,
   then hang up.

 * Otherwise, if ~/git-shell-commands/ is present, start an
   interactive read-eval-print loop.

 * Otherwise, print the usual configuration hint and hang up.

Reported-by: Ethan Reesor firelizz...@gmail.com
Signed-off-by: Jonathan Nieder jrnie...@gmail.com
Improved-by: Jeff King p...@peff.net
---
v2 jammed this functionality into the help command, which was kind
of silly.  Hopefully this version's better.

This is not urgent at all.  If it looks like a good change, I'd be
happy to see it be a part of the 1.8.3 cycle.

Thoughts?
Jonathan

 Documentation/git-shell.txt | 20 
 shell.c | 13 +
 2 files changed, 33 insertions(+)

diff --git a/Documentation/git-shell.txt b/Documentation/git-shell.txt
index 544b21aa..c35051ba 100644
--- a/Documentation/git-shell.txt
+++ b/Documentation/git-shell.txt
@@ -59,6 +59,26 @@ users to list repositories they have access to, create, 
delete, or
 rename repositories, or change repository descriptions and
 permissions.
 
+If a `no-interactive-login` command exists, then it is run and the
+interactive shell is aborted.
+
+EXAMPLE
+---
+
+To disable interactive logins, displaying a greeting instead:
++
+
+$ chsh -s /usr/bin/git-shell
+$ mkdir $HOME/git-shell-commands
+$ cat $HOME/git-shell-commands/no-interactive-login \EOF
+#!/bin/sh
+printf '%s\n' Hi $USER! You've successfully authenticated, but I do not
+printf '%s\n' provide interactive shell access.
+exit 128
+EOF
+$ chmod +x $HOME/git-shell-commands/no-interactive-login
+
+
 SEE ALSO
 
 ssh(1),
diff --git a/shell.c b/shell.c
index 84b237fe..1429870a 100644
--- a/shell.c
+++ b/shell.c
@@ -6,6 +6,7 @@
 
 #define COMMAND_DIR git-shell-commands
 #define HELP_COMMAND COMMAND_DIR /help
+#define NOLOGIN_COMMAND COMMAND_DIR /no-interactive-login
 
 static int do_generic_cmd(const char *me, char *arg)
 {
@@ -65,6 +66,18 @@ static void run_shell(void)
 {
int done = 0;
static const char *help_argv[] = { HELP_COMMAND, NULL };
+
+   if (!access(NOLOGIN_COMMAND, F_OK)) {
+   /* Interactive login disabled. */
+   const char *argv[] = { NOLOGIN_COMMAND, NULL };
+   int status;
+
+   status = run_command_v_opt(argv, 0);
+   if (status  0)
+   exit(127);
+   exit(status);
+   }
+
/* Print help if enabled */
run_command_v_opt(help_argv, RUN_SILENT_EXEC_FAILURE);
 
-- 
1.8.2.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


[PATCH] git.c: Remove unnecessary new line

2013-03-09 Thread Michael Fallows

New line on checkout-index is inconsistent with the rest of the commands

Signed-off-by: Michael Fallows mich...@fallo.ws
---
 git.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/git.c b/git.c
index b10c18b..b4d7bbb 100644
--- a/git.c
+++ b/git.c
@@ -316,8 +316,7 @@ static void handle_internal_command(int argc, const 
char **argv)

{ check-ignore, cmd_check_ignore, RUN_SETUP | NEED_WORK_TREE 
},
{ check-ref-format, cmd_check_ref_format },
{ checkout, cmd_checkout, RUN_SETUP | NEED_WORK_TREE },
-   { checkout-index, cmd_checkout_index,
-   RUN_SETUP | NEED_WORK_TREE},
+   { checkout-index, cmd_checkout_index, RUN_SETUP | 
NEED_WORK_TREE },
{ cherry, cmd_cherry, RUN_SETUP },
{ cherry-pick, cmd_cherry_pick, RUN_SETUP | NEED_WORK_TREE },
{ clean, cmd_clean, RUN_SETUP | NEED_WORK_TREE },
--
1.7.9.5
--
To unsubscribe from this list: send the line 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.c: Remove unnecessary new line

2013-03-09 Thread Michael Fallows
New line on checkout-index is inconsistent with the rest of the commands

Signed-off-by: Michael Fallows mich...@fallo.ws
---
 git.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/git.c b/git.c
index b10c18b..b4d7bbb 100644
--- a/git.c
+++ b/git.c
@@ -316,8 +316,7 @@ static void handle_internal_command(int argc, const char 
**argv)
{ check-ignore, cmd_check_ignore, RUN_SETUP | NEED_WORK_TREE 
},
{ check-ref-format, cmd_check_ref_format },
{ checkout, cmd_checkout, RUN_SETUP | NEED_WORK_TREE },
-   { checkout-index, cmd_checkout_index,
-   RUN_SETUP | NEED_WORK_TREE},
+   { checkout-index, cmd_checkout_index, RUN_SETUP | 
NEED_WORK_TREE },
{ cherry, cmd_cherry, RUN_SETUP },
{ cherry-pick, cmd_cherry_pick, RUN_SETUP | NEED_WORK_TREE },
{ clean, cmd_clean, RUN_SETUP | NEED_WORK_TREE },
-- 
1.7.9.5

--
To unsubscribe from this list: send the line 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] git.c: Remove unnecessary new line

2013-03-09 Thread Michael Fallows
From 8750dc231a2b973efa18aff4dbc5b2ace7c79c47 Mon Sep 17 00:00:00 2001
From: Michael Fallows mich...@fallo.ws
Date: Sat, 9 Mar 2013 21:47:11 +
Subject: [PATCH] git.c: Remove unnecessary new line

New line on checkout-index is inconsistent with the rest of the commands

Signed-off-by: Michael Fallows mich...@fallo.ws
---
 git.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/git.c b/git.c
index b10c18b..b4d7bbb 100644
--- a/git.c
+++ b/git.c
@@ -316,8 +316,7 @@ static void handle_internal_command(int argc, const char 
**argv)
{ check-ignore, cmd_check_ignore, RUN_SETUP | NEED_WORK_TREE 
},
{ check-ref-format, cmd_check_ref_format },
{ checkout, cmd_checkout, RUN_SETUP | NEED_WORK_TREE },
-   { checkout-index, cmd_checkout_index,
-   RUN_SETUP | NEED_WORK_TREE},
+   { checkout-index, cmd_checkout_index, RUN_SETUP | 
NEED_WORK_TREE },
{ cherry, cmd_cherry, RUN_SETUP },
{ cherry-pick, cmd_cherry_pick, RUN_SETUP | NEED_WORK_TREE },
{ clean, cmd_clean, RUN_SETUP | NEED_WORK_TREE },
-- 
1.7.9.5
--
To unsubscribe from this list: send the line 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] setup.c: Fix prefix_pathspec from looping pass end of string

2013-03-09 Thread Andrew Wong
The previous code was assuming length ends at either ) or ,, and was
not handling the case where strcspn returns length due to end of string.
So specifying :(top as pathspec will cause the loop to go pass the end
of string.

Signed-off-by: Andrew Wong andrew.k...@gmail.com
---
 setup.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/setup.c b/setup.c
index 1dee47e..f4c4e73 100644
--- a/setup.c
+++ b/setup.c
@@ -207,9 +207,11 @@ static const char *prefix_pathspec(const char *prefix, int 
prefixlen, const char
 *copyfrom  *copyfrom != ')';
 copyfrom = nextat) {
size_t len = strcspn(copyfrom, ,));
-   if (copyfrom[len] == ')')
+   if (copyfrom[len] == '\0')
nextat = copyfrom + len;
-   else
+   else if (copyfrom[len] == ')')
+   nextat = copyfrom + len;
+   else if (copyfrom[len] == ',')
nextat = copyfrom + len + 1;
if (!len)
continue;
-- 
1.7.12.4

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


[PATCH 2/2] setup.c: Check that the pathspec magic ends with )

2013-03-09 Thread Andrew Wong
The previous code allowed the ) to be optional.

Signed-off-by: Andrew Wong andrew.k...@gmail.com
---
 setup.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/setup.c b/setup.c
index f4c4e73..5ed2b93 100644
--- a/setup.c
+++ b/setup.c
@@ -225,8 +225,9 @@ static const char *prefix_pathspec(const char *prefix, int 
prefixlen, const char
die(Invalid pathspec magic '%.*s' in '%s',
(int) len, copyfrom, elt);
}
-   if (*copyfrom == ')')
-   copyfrom++;
+   if (*copyfrom != ')')
+   die(Missing ')' at the end of pathspec magic in '%s', 
elt);
+   copyfrom++;
} else {
/* shorthand */
for (copyfrom = elt + 1;
-- 
1.7.12.4

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


Re: [PATCH v2] git.c: Remove unnecessary new line

2013-03-09 Thread Jonathan Nieder
Hi,

Michael Fallows wrote:

 --- a/git.c
 +++ b/git.c
 @@ -316,8 +316,7 @@ static void handle_internal_command(int argc, const char 
 **argv)
   { check-ignore, cmd_check_ignore, RUN_SETUP | NEED_WORK_TREE 
 },
   { check-ref-format, cmd_check_ref_format },
   { checkout, cmd_checkout, RUN_SETUP | NEED_WORK_TREE },
 - { checkout-index, cmd_checkout_index,
 - RUN_SETUP | NEED_WORK_TREE},
 + { checkout-index, cmd_checkout_index, RUN_SETUP | 
 NEED_WORK_TREE },

This wrapped line was introduced a while ago (4465f410, checkout-index
needs a working tree, 2007-08-04).  It was the first line to wrap, but
it was also the longest line at the time.

Now the longest line is

{ merge-recursive-theirs, cmd_merge_recursive, RUN_SETUP | 
NEED_WORK_TREE },

(94 columns), so you are right that consistency would suggest dropping
the line wrapping for checkout-index.

But I find it hard to convince myself that alone is worth the churn.
In what context did you notice this?  Is the intent to help scripts to
parse the commands[] list, or to manipulate it while preserving
formatting to avoid distractions?  Did you notice the broken line
while reading through and get distracted, or did some syntax
highlighting tool notice the oddity, or something else?

Hope that helps,
Jonathan
--
To unsubscribe from this list: send the line 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/3] mergetools/p4merge: create a base if none available

2013-03-09 Thread Kevin Bracey
Originally, with no base, Git gave P4Merge $LOCAL as a dummy base:

   p4merge $LOCAL $LOCAL $REMOTE $MERGED

Commit 0a0ec7bd changed this to:

   p4merge empty file $LOCAL $REMOTE $MERGED

to avoid the problem of being unable to save in some circumstances with
similar inputs.

Unfortunately this approach produces much worse results on differing
inputs. P4Merge really regards the blank file as the base, and once you
have just a couple of differences between the two branches you end up
with one a massive full-file conflict. The 3-way diff is not readable,
and you have to invoke difftool MERGE_HEAD HEAD manually to get a
useful view.

The original approach appears to have invoked special 2-way merge
behaviour in P4Merge that occurs only if the base filename is  or
equal to the left input.  You get a good visual comparison, and it does
not auto-resolve differences. (Normally if one branch matched the base,
it would autoresolve to the other branch).

But there appears to be no way of getting this 2-way behaviour and being
able to reliably save. Having base==left appears to be triggering other
assumptions. There are tricks the user can use to force the save icon
on, but it's not intuitive.

So we now follow a suggestion given in the original patch's discussion:
generate a virtual base, consisting of the lines common to the two
branches. This is the same as the technique used in resolve and octopus
merges, so we relocate that code to a shared function.

Note that if there are no differences at the same location, this
technique can lead to automatic resolution without conflict, combining
everything from the 2 files.  As with the other merges using this
technique, we assume the user will inspect the result before saving.

Signed-off-by: Kevin Bracey ke...@bracey.fi
---
 git-merge-one-file.sh | 18 +-
 git-sh-setup.sh   | 13 +
 mergetools/p4merge|  6 +-
 3 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/git-merge-one-file.sh b/git-merge-one-file.sh
index f612cb8..1236fbf 100755
--- a/git-merge-one-file.sh
+++ b/git-merge-one-file.sh
@@ -104,30 +104,22 @@ case ${1:-.}${2:-.}${3:-.} in
;;
esac
 
-   src2=`git-unpack-file $3`
+   src1=$(git-unpack-file $2)
+   src2=$(git-unpack-file $3)
case $1 in
'')
echo Added $4 in both, but differently.
-   # This extracts OUR file in $orig, and uses git apply to
-   # remove lines that are unique to ours.
-   orig=`git-unpack-file $2`
-   sz0=`wc -c $orig`
-   @@DIFF@@ -u -La/$orig -Lb/$orig $orig $src2 | git apply --no-add
-   sz1=`wc -c $orig`
-
-   # If we do not have enough common material, it is not
-   # worth trying two-file merge using common subsections.
-   expr $sz0 \ $sz1 \* 2 /dev/null || : $orig
+   orig=$(git-unpack-file $2)
+   create_virtual_base $orig $src1 $src2
;;
*)
echo Auto-merging $4
-   orig=`git-unpack-file $1`
+   orig=$(git-unpack-file $1)
;;
esac
 
# Be careful for funny filename such as -L in $4, which
# would confuse merge greatly.
-   src1=`git-unpack-file $2`
git merge-file $src1 $orig $src2
ret=$?
msg=
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index 795edd2..aa9a732 100644
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -249,6 +249,19 @@ clear_local_git_env() {
unset $(git rev-parse --local-env-vars)
 }
 
+# Generate a virtual base file for a two-file merge. On entry the
+# base file $1 should be a copy of $2. Uses git apply to remove
+# lines from $1 that are not in $3, leaving only common lines.
+create_virtual_base() {
+   sz0=$(wc -c $1)
+   @@DIFF@@ -u -La/$1 -Lb/$1 $2 $3 | git apply --no-add
+   sz1=$(wc -c $1)
+
+   # If we do not have enough common material, it is not
+   # worth trying two-file merge using common subsections.
+   expr $sz0 \ $sz1 \* 2 /dev/null || : $1
+}
+
 
 # Platform specific tweaks to work around some commands
 case $(uname -s) in
diff --git a/mergetools/p4merge b/mergetools/p4merge
index 46b3a5a..16ae0cc 100644
--- a/mergetools/p4merge
+++ b/mergetools/p4merge
@@ -21,7 +21,11 @@ diff_cmd () {
 
 merge_cmd () {
touch $BACKUP
-   $base_present || $BASE
+   if ! $base_present
+   then
+   cp -- $LOCAL $BASE
+   create_virtual_base $BASE $LOCAL $REMOTE
+   fi
$merge_tool_path $BASE $REMOTE $LOCAL $MERGED
check_unchanged
 }
-- 
1.8.2.rc3.7.g77aeedb

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


Re: [PATCH 2/2] shell: new no-interactive-login command to print a custom message

2013-03-09 Thread Junio C Hamano
Jonathan Nieder jrnie...@gmail.com writes:

 If I disable git-shell's interactive mode by removing the
 ~/git-shell-commands directory, attempts to use 'ssh' in produce a
 message intended for the administrator:

Sorry, but -ECANTPARSE.  s/in produce/produces/ perhaps?  Or if you
meant ssh in as a verb, then attempts to ssh in to the service
produces a message.  I dunno.

Patch text looks good, including the documentation.

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 2/2] shell: new no-interactive-login command to print a custom message

2013-03-09 Thread Jonathan Nieder
Junio C Hamano wrote:
 Jonathan Nieder jrnie...@gmail.com writes:

 If I disable git-shell's interactive mode by removing the
 ~/git-shell-commands directory, attempts to use 'ssh' in produce a
 message intended for the administrator:

 Sorry, but -ECANTPARSE.  s/in produce/produces/ perhaps?  Or if you
 meant ssh in as a verb, then attempts to ssh in to the service
 produces a message.  I dunno.

Sloppy of me.  Yes, it should say something like this:

If I disable git-shell's interactive mode by removing the
~/git-shell-commands directory, attempts to ssh in to the service
produce a message intended for the administrator:
--
To unsubscribe from this list: send the line 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/6] Exclude optimizations

2013-03-09 Thread Nguyễn Thái Ngọc Duy
v2 includes strncmp_equal and directory level pattern filter. user
time of git ls-files --exclude-standard -o on webkit.git below.
Looking pretty good.

before  after
user0m0.607s0m0.365s
user0m0.613s0m0.366s
user0m0.613s0m0.374s
user0m0.621s0m0.374s
user0m0.621s0m0.377s
user0m0.622s0m0.381s
user0m0.624s0m0.381s
user0m0.626s0m0.383s
user0m0.628s0m0.384s
user0m0.638s0m0.384s


Nguyễn Thái Ngọc Duy (6):
  match_pathname: avoid calling strncmp if baselen is 0
  dir.c: inline convenient *_icase helpers
  match_basename: use strncmp instead of strcmp
  match_{base,path}name: replace strncmp_icase with strnequal_icase
  dir.c: pass pathname length to last_exclude_matching
  exclude: filter patterns by directory level

 attr.c |   5 ++-
 dir.c  | 114 -
 dir.h  |  27 +---
 3 files changed, 104 insertions(+), 42 deletions(-)

-- 
1.8.1.2.536.gf441e6d

--
To unsubscribe from this list: send the line 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/6] match_pathname: avoid calling strncmp if baselen is 0

2013-03-09 Thread Nguyễn Thái Ngọc Duy
This reduces git status user time by a little bit. This is the
sorted results of 10 consecutive runs of git ls-files
--exclude-standard -o on webkit.git, compiled with gcc -O2:

before  after
user0m0.607s0m0.554s
user0m0.613s0m0.564s
user0m0.613s0m0.571s
user0m0.621s0m0.576s
user0m0.621s0m0.578s
user0m0.622s0m0.579s
user0m0.624s0m0.583s
user0m0.626s0m0.584s
user0m0.628s0m0.586s
user0m0.638s0m0.592s

Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com
---
 dir.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/dir.c b/dir.c
index 57394e4..b3cd66c 100644
--- a/dir.c
+++ b/dir.c
@@ -662,8 +662,8 @@ int match_pathname(const char *pathname, int pathlen,
 * may not end with a trailing slash though.
 */
if (pathlen  baselen + 1 ||
-   (baselen  pathname[baselen] != '/') ||
-   strncmp_icase(pathname, base, baselen))
+   (baselen  (pathname[baselen] != '/' ||
+strncmp_icase(pathname, base, baselen
return 0;
 
namelen = baselen ? pathlen - baselen - 1 : pathlen;
-- 
1.8.1.2.536.gf441e6d

--
To unsubscribe from this list: send the line 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/6] dir.c: inline convenient *_icase helpers

2013-03-09 Thread Nguyễn Thái Ngọc Duy
Like the previous patch, this cuts down the number of str*cmp calls in
read_directory (which does _a lot_). Again sorted results on webkit.git:

before  after
user0m0.554s0m0.548s
user0m0.564s0m0.549s
user0m0.571s0m0.554s
user0m0.576s0m0.557s
user0m0.578s0m0.558s
user0m0.579s0m0.559s
user0m0.583s0m0.562s
user0m0.584s0m0.564s
user0m0.586s0m0.566s
user0m0.592s0m0.569s

Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com
---
 dir.c | 16 
 dir.h | 18 +++---
 2 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/dir.c b/dir.c
index b3cd66c..9960a37 100644
--- a/dir.c
+++ b/dir.c
@@ -21,22 +21,6 @@ static int read_directory_recursive(struct dir_struct *dir, 
const char *path, in
int check_only, const struct path_simplify *simplify);
 static int get_dtype(struct dirent *de, const char *path, int len);
 
-/* helper string functions with support for the ignore_case flag */
-int strcmp_icase(const char *a, const char *b)
-{
-   return ignore_case ? strcasecmp(a, b) : strcmp(a, b);
-}
-
-int strncmp_icase(const char *a, const char *b, size_t count)
-{
-   return ignore_case ? strncasecmp(a, b, count) : strncmp(a, b, count);
-}
-
-int fnmatch_icase(const char *pattern, const char *string, int flags)
-{
-   return fnmatch(pattern, string, flags | (ignore_case ? FNM_CASEFOLD : 
0));
-}
-
 inline int git_fnmatch(const char *pattern, const char *string,
   int flags, int prefix)
 {
diff --git a/dir.h b/dir.h
index c3eb4b5..560ade4 100644
--- a/dir.h
+++ b/dir.h
@@ -200,9 +200,21 @@ extern int remove_dir_recursively(struct strbuf *path, int 
flag);
 /* tries to remove the path with empty directories along it, ignores ENOENT */
 extern int remove_path(const char *path);
 
-extern int strcmp_icase(const char *a, const char *b);
-extern int strncmp_icase(const char *a, const char *b, size_t count);
-extern int fnmatch_icase(const char *pattern, const char *string, int flags);
+/* helper string functions with support for the ignore_case flag */
+static inline int strcmp_icase(const char *a, const char *b)
+{
+   return ignore_case ? strcasecmp(a, b) : strcmp(a, b);
+}
+
+static inline int strncmp_icase(const char *a, const char *b, size_t count)
+{
+   return ignore_case ? strncasecmp(a, b, count) : strncmp(a, b, count);
+}
+
+static inline int fnmatch_icase(const char *pattern, const char *string, int 
flags)
+{
+   return fnmatch(pattern, string, flags | (ignore_case ? FNM_CASEFOLD : 
0));
+}
 
 /*
  * The prefix part of pattern must not contains wildcards.
-- 
1.8.1.2.536.gf441e6d

--
To unsubscribe from this list: send the line 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/6] match_basename: use strncmp instead of strcmp

2013-03-09 Thread Nguyễn Thái Ngọc Duy
strncmp is provided length information which could be taken advantage
by the underlying implementation. Even better, we need to check if the
lengths are equal before calling strncmp, eliminating a bit of strncmp
calls.

before  after
user0m0.548s0m0.516s
user0m0.549s0m0.523s
user0m0.554s0m0.532s
user0m0.557s0m0.533s
user0m0.558s0m0.535s
user0m0.559s0m0.542s
user0m0.562s0m0.546s
user0m0.564s0m0.551s
user0m0.566s0m0.556s
user0m0.569s0m0.561s

While at there, fix an inconsistency about pattern/patternlen in how
attr handles EXC_FLAG_MUSTBEDIR. When parse_exclude_pattern detects
this flag, it sets patternlen _not_ to include the trailing slash and
expects the caller to trim it. add_exclude does, parse_attr_line does
not.

In attr.c, the pattern could be foo/ while patternlen tells us it
only has 3 chars. Some functions do not care about patternlen and will
see the pattern as foo/ while others may see it as foo. This patch
makes patternlen 4 in this case. (Although for a piece of mind,
perhaps we should trim it to foo like exclude, and never pass a
pathname like abc/ to match_{base,path}name)

Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com
---
 attr.c | 2 ++
 dir.c  | 8 +---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/attr.c b/attr.c
index e2f9377..1818ba5 100644
--- a/attr.c
+++ b/attr.c
@@ -255,6 +255,8 @@ static struct match_attr *parse_attr_line(const char *line, 
const char *src,
  res-u.pat.patternlen,
  res-u.pat.flags,
  res-u.pat.nowildcardlen);
+   if (res-u.pat.flags  EXC_FLAG_MUSTBEDIR)
+   res-u.pat.patternlen++;
if (res-u.pat.flags  EXC_FLAG_NEGATIVE) {
warning(_(Negative patterns are ignored in git 
attributes\n
  Use '\\!' for literal leading 
exclamation.));
diff --git a/dir.c b/dir.c
index 9960a37..46b24db 100644
--- a/dir.c
+++ b/dir.c
@@ -610,12 +610,14 @@ int match_basename(const char *basename, int basenamelen,
   int flags)
 {
if (prefix == patternlen) {
-   if (!strcmp_icase(pattern, basename))
+   if (patternlen == basenamelen 
+   !strncmp_icase(pattern, basename, patternlen))
return 1;
} else if (flags  EXC_FLAG_ENDSWITH) {
if (patternlen - 1 = basenamelen 
-   !strcmp_icase(pattern + 1,
- basename + basenamelen - patternlen + 1))
+   !strncmp_icase(pattern + 1,
+  basename + basenamelen - patternlen + 1,
+  patternlen - 1))
return 1;
} else {
if (fnmatch_icase(pattern, basename, 0) == 0)
-- 
1.8.1.2.536.gf441e6d

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


[PATCH v2 4/6] match_{base,path}name: replace strncmp_icase with strnequal_icase

2013-03-09 Thread Nguyễn Thái Ngọc Duy
We could also optimize for ignore_case, assuming that non-ascii
characters are not used in most repositories. We could check that all
patterns and pathnames are ascii-only, then use git's toupper()

before  after
user0m0.516s0m0.433s
user0m0.523s0m0.437s
user0m0.532s0m0.443s
user0m0.533s0m0.448s
user0m0.535s0m0.449s
user0m0.542s0m0.452s
user0m0.546s0m0.453s
user0m0.551s0m0.458s
user0m0.556s0m0.459s
user0m0.561s0m0.462s

Suggested-by: Fredrik Gustafsson iv...@iveqy.com
Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com
---
 dir.c | 27 +++
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/dir.c b/dir.c
index 46b24db..7b6a625 100644
--- a/dir.c
+++ b/dir.c
@@ -21,6 +21,25 @@ static int read_directory_recursive(struct dir_struct *dir, 
const char *path, in
int check_only, const struct path_simplify *simplify);
 static int get_dtype(struct dirent *de, const char *path, int len);
 
+/*
+ * This function is more like memequal_icase than strnequal_icase as
+ * it does not check for NUL. The caller is not supposed to pass a
+ * length longer than both input strings
+ */
+static inline strnequal_icase(const char *a, const char *b, int n)
+{
+   if (!ignore_case) {
+   while (n  *a == *b) {
+   a++;
+   b++;
+   n--;
+   }
+   return n == 0;
+   }
+
+   return !strncmp_icase(a, b, n);
+}
+
 inline int git_fnmatch(const char *pattern, const char *string,
   int flags, int prefix)
 {
@@ -611,11 +630,11 @@ int match_basename(const char *basename, int basenamelen,
 {
if (prefix == patternlen) {
if (patternlen == basenamelen 
-   !strncmp_icase(pattern, basename, patternlen))
+   strnequal_icase(pattern, basename, patternlen))
return 1;
} else if (flags  EXC_FLAG_ENDSWITH) {
if (patternlen - 1 = basenamelen 
-   !strncmp_icase(pattern + 1,
+   strnequal_icase(pattern + 1,
   basename + basenamelen - patternlen + 1,
   patternlen - 1))
return 1;
@@ -649,7 +668,7 @@ int match_pathname(const char *pathname, int pathlen,
 */
if (pathlen  baselen + 1 ||
(baselen  (pathname[baselen] != '/' ||
-strncmp_icase(pathname, base, baselen
+!strnequal_icase(pathname, base, baselen
return 0;
 
namelen = baselen ? pathlen - baselen - 1 : pathlen;
@@ -663,7 +682,7 @@ int match_pathname(const char *pathname, int pathlen,
if (prefix  namelen)
return 0;
 
-   if (strncmp_icase(pattern, name, prefix))
+   if (!strnequal_icase(pattern, name, prefix))
return 0;
pattern += prefix;
name+= prefix;
-- 
1.8.1.2.536.gf441e6d

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


[PATCH v2 5/6] dir.c: pass pathname length to last_exclude_matching

2013-03-09 Thread Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com
---
 dir.c | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/dir.c b/dir.c
index 7b6a625..880b5e6 100644
--- a/dir.c
+++ b/dir.c
@@ -764,9 +764,9 @@ int is_excluded_from_list(const char *pathname,
  */
 static struct exclude *last_exclude_matching(struct dir_struct *dir,
 const char *pathname,
+int pathlen,
 int *dtype_p)
 {
-   int pathlen = strlen(pathname);
int i, j;
struct exclude_list_group *group;
struct exclude *exclude;
@@ -793,10 +793,12 @@ static struct exclude *last_exclude_matching(struct 
dir_struct *dir,
  * scans all exclude lists to determine whether pathname is excluded.
  * Returns 1 if true, otherwise 0.
  */
-static int is_excluded(struct dir_struct *dir, const char *pathname, int 
*dtype_p)
+static int is_excluded(struct dir_struct *dir,
+  const char *pathname, int pathlen,
+  int *dtype_p)
 {
struct exclude *exclude =
-   last_exclude_matching(dir, pathname, dtype_p);
+   last_exclude_matching(dir, pathname, pathlen, dtype_p);
if (exclude)
return exclude-flags  EXC_FLAG_NEGATIVE ? 0 : 1;
return 0;
@@ -859,7 +861,8 @@ struct exclude *last_exclude_matching_path(struct 
path_exclude_check *check,
if (ch == '/') {
int dt = DT_DIR;
exclude = last_exclude_matching(check-dir,
-   path-buf, dt);
+   path-buf, path-len,
+   dt);
if (exclude) {
check-exclude = exclude;
return exclude;
@@ -871,7 +874,7 @@ struct exclude *last_exclude_matching_path(struct 
path_exclude_check *check,
/* An entry in the index; cannot be a directory with subentries */
strbuf_setlen(path, 0);
 
-   return last_exclude_matching(check-dir, name, dtype);
+   return last_exclude_matching(check-dir, name, namelen, dtype);
 }
 
 /*
@@ -1249,7 +1252,7 @@ static enum path_treatment treat_one_path(struct 
dir_struct *dir,
  const struct path_simplify *simplify,
  int dtype, struct dirent *de)
 {
-   int exclude = is_excluded(dir, path-buf, dtype);
+   int exclude = is_excluded(dir, path-buf, path-len, dtype);
if (exclude  (dir-flags  DIR_COLLECT_IGNORED)
 exclude_matches_pathspec(path-buf, path-len, simplify))
dir_add_ignored(dir, path-buf, path-len);
-- 
1.8.1.2.536.gf441e6d

--
To unsubscribe from this list: send the line 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/6] exclude: filter patterns by directory level

2013-03-09 Thread Nguyễn Thái Ngọc Duy
A non-basename pattern that does not contain /**/ can't match anything
outside the attached directory. Record its directory level and avoid
matching unless the pathname is also at the same directory level.

This optimization shines when there are a lot of non-basename patterns
are the root .gitignore and big/deep worktree. Due to the cascading
rule of .gitignore, patterns in the root .gitignore are checked for
_all_ entries in the worktree.

before  after
user0m0.424s0m0.365s
user0m0.427s0m0.366s
user0m0.432s0m0.374s
user0m0.435s0m0.374s
user0m0.435s0m0.377s
user0m0.437s0m0.381s
user0m0.439s0m0.381s
user0m0.440s0m0.383s
user0m0.450s0m0.384s
user0m0.454s0m0.384s

Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com
---
 attr.c |  3 ++-
 dir.c  | 68 --
 dir.h  |  9 -
 3 files changed, 60 insertions(+), 20 deletions(-)

diff --git a/attr.c b/attr.c
index 1818ba5..7764ddd 100644
--- a/attr.c
+++ b/attr.c
@@ -254,7 +254,8 @@ static struct match_attr *parse_attr_line(const char *line, 
const char *src,
parse_exclude_pattern(res-u.pat.pattern,
  res-u.pat.patternlen,
  res-u.pat.flags,
- res-u.pat.nowildcardlen);
+ res-u.pat.nowildcardlen,
+ NULL);
if (res-u.pat.flags  EXC_FLAG_MUSTBEDIR)
res-u.pat.patternlen++;
if (res-u.pat.flags  EXC_FLAG_NEGATIVE) {
diff --git a/dir.c b/dir.c
index 880b5e6..de7a6ba 100644
--- a/dir.c
+++ b/dir.c
@@ -360,10 +360,12 @@ static int no_wildcard(const char *string)
 void parse_exclude_pattern(const char **pattern,
   int *patternlen,
   int *flags,
-  int *nowildcardlen)
+  int *nowildcardlen,
+  int *dirs_p)
 {
const char *p = *pattern;
size_t i, len;
+   int dirs;
 
*flags = 0;
if (*p == '!') {
@@ -375,12 +377,15 @@ void parse_exclude_pattern(const char **pattern,
len--;
*flags |= EXC_FLAG_MUSTBEDIR;
}
-   for (i = 0; i  len; i++) {
+   for (i = 0, dirs = 0; i  len; i++) {
if (p[i] == '/')
-   break;
+   dirs++;
}
-   if (i == len)
+   if (!dirs)
*flags |= EXC_FLAG_NODIR;
+   else if (*p == '/')
+   dirs--;
+
*nowildcardlen = simple_length(p);
/*
 * we should have excluded the trailing slash from 'p' too,
@@ -393,6 +398,8 @@ void parse_exclude_pattern(const char **pattern,
*flags |= EXC_FLAG_ENDSWITH;
*pattern = p;
*patternlen = len;
+   if (dirs_p)
+   *dirs_p = dirs;
 }
 
 void add_exclude(const char *string, const char *base,
@@ -402,8 +409,9 @@ void add_exclude(const char *string, const char *base,
int patternlen;
int flags;
int nowildcardlen;
+   int dirs;
 
-   parse_exclude_pattern(string, patternlen, flags, nowildcardlen);
+   parse_exclude_pattern(string, patternlen, flags, nowildcardlen, 
dirs);
if (flags  EXC_FLAG_MUSTBEDIR) {
char *s;
x = xmalloc(sizeof(*x) + patternlen + 1);
@@ -415,11 +423,26 @@ void add_exclude(const char *string, const char *base,
x = xmalloc(sizeof(*x));
x-pattern = string;
}
+   /*
+* TODO: nowildcardlen  patternlen is a stricter than
+* necessary mainly to exclude ** that breaks directory
+* boundary. Patterns like /foo-* should be fine.
+*/
+   if ((flags  EXC_FLAG_NODIR) || nowildcardlen  patternlen)
+   dirs = -1;
+   else {
+   int i;
+   for (i = 0; i  baselen; i++) {
+   if (base[i] == '/')
+   dirs++;
+   }
+   }
x-patternlen = patternlen;
x-nowildcardlen = nowildcardlen;
x-base = base;
x-baselen = baselen;
x-flags = flags;
+   x-dirs = dirs;
x-srcpos = srcpos;
ALLOC_GROW(el-excludes, el-nr + 1, el-alloc);
el-excludes[el-nr++] = x;
@@ -701,7 +724,7 @@ int match_pathname(const char *pathname, int pathlen,
  * matched, or NULL for undecided.
  */
 static struct exclude *last_exclude_matching_from_list(const char *pathname,
-  int pathlen,
+  int pathlen, int dirs,
   const char *basename,
   int *dtype,
 

Re: [PATCH] format-patch: RFC 2047 says multi-octet character may not be split

2013-03-09 Thread Kirill Smelkov
On Sat, Mar 09, 2013 at 11:07:19AM -0800, Junio C Hamano wrote:
 Kirill Smelkov k...@navytux.spb.ru writes:
  P.S. sorry for the delay - I harmed my arm yesterday.
 
 Ouch. Take care and be well soon.

Thanks, and thanks fr accepting the patch.
--
To unsubscribe from this list: send the line 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: Memory corruption when rebasing with git version 1.8.1.5 on arch

2013-03-09 Thread Jeff King
On Sat, Mar 09, 2013 at 11:54:36AM +0100, Bernhard Posselt wrote:

 Also, I can almost reproduce here, as PatrickHeller/core.git is public.
 However, I suspect the problem is particular to your work built on top,
 which looks like it is at commit 0525bbd73c9015499ba92d1ac654b980aaca35b2.
 Is it possible for you to make that commit available on a temporary
 branch?

 What do you mean exactly by that?

I just meant to push the work from your local repository somewhere where
I could access it to try to replicate the issue. What you did here:

 git clone https://github.com/Raydiation/memorycorruption
 cd memorycorruption
 git pull --rebase https://github.com/Raydiation/core

...should be plenty. Unfortunately, I'm not able to reproduce the
segfault.  All of the patches apply fine, both normally and when run
under valgrind.

 Heres the output of the GIT_TRACE file
 [...]
 trace: built-in: git 'apply' '--index' 
 '/srv/http/owncloud/.git/rebase-apply/patch'

This confirms my suspicion that the problem is in git apply.

You had mentioned before that the valgrind log was very long.  If you're
still able to reproduce, could you try running it with valgrind like
this:

  valgrind -q --trace-children=yes --log-file=/tmp/valgrind.out \
git pull --rebase https://github.com/Raydiation/core

Logging to a file instead of stderr should mean we still get output for
commands that are invoked with their stderr redirected (which is the
case for the git apply in question), and using -q should eliminate
the uninteresting cruft from the log.

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


Re: [PATCH v2 3/6] match_basename: use strncmp instead of strcmp

2013-03-09 Thread Junio C Hamano
Nguyễn Thái Ngọc Duy  pclo...@gmail.com writes:

 strncmp is provided length information which could be taken advantage
 by the underlying implementation.

I may be missing something fundamental, but I somehow find the above
does not make any sense.

strcmp(a, b) has to pay attention to NUL in these strings and stop
comparison.  strncmp(a, b, n) not only has to pay the same attention
to NUL in the strings, but also needs to stop comparing at n bytes.

In what situation can the latter take advantage of that extra thing
that it needs to keep track of and operate faster, when n is the
length of shorter of the two strings?

 diff --git a/dir.c b/dir.c
 index 9960a37..46b24db 100644
 --- a/dir.c
 +++ b/dir.c
 @@ -610,12 +610,14 @@ int match_basename(const char *basename, int 
 basenamelen,
  int flags)
  {
   if (prefix == patternlen) {
 - if (!strcmp_icase(pattern, basename))
 + if (patternlen == basenamelen 
 + !strncmp_icase(pattern, basename, patternlen))
   return 1;

What happens if you replace this with

if (patternlen == baselen 
!strcmp_icase(pattern, basename, patternlen))

and drop the other hunk and run the benchmark again?

   } else if (flags  EXC_FLAG_ENDSWITH) {
   if (patternlen - 1 = basenamelen 
 - !strcmp_icase(pattern + 1,
 -   basename + basenamelen - patternlen + 1))
 + !strncmp_icase(pattern + 1,
 +basename + basenamelen - patternlen + 1,
 +patternlen - 1))
   return 1;
   } else {
   if (fnmatch_icase(pattern, basename, 0) == 0)
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html