the .git folder

2014-04-20 Thread Miller, Hugh
Dear Community,

Is there any way to use .git (e.g., a different set of client commands) that 
allows the .git folder to be placed in a location away from the actual files 
being versioned ? For example, can one set environment variables that let the 
software know where the .git folder is ?

Reason for asking - the files being versioned are acted on other applications 
that know nothing about git, so presence of .git in the file directory may 
cause problems.

Thanks,

Hugh Miller
--
To unsubscribe from this list: send the line 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: the .git folder

2014-04-20 Thread Duy Nguyen
On Sun, Apr 20, 2014 at 4:13 PM, Miller, Hugh hughmil...@chevron.com wrote:
 Dear Community,

 Is there any way to use .git (e.g., a different set of client commands) 
 that allows the .git folder to be placed in a location away from the actual 
 files being versioned ? For example, can one set environment variables that 
 let the software know where the .git folder is ?

Try

git --git-dir=new .git location --work-tree=top work tree location
some command

The reason of two arguments instead of one is because .git is also
used to mark top work tree location, which is now lost after you move
.git elsewhere. You could also set environment variables GIT_DIR and
GIT_WORK_TREE, which have the same effect. man git for details.
-- 
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


Project idea: github-like diff view

2014-04-20 Thread Duy Nguyen
When you view a commit from github, it shows extra info besides
standard unified diff format:

- the column number of each line (useful for jumping directly to that
line without manual counting from @@ line)
- --color-words within unified diff format, using background color to
show what part of the line has changed. This is only enabled for
1-line changes.

These can be implemented and seem useful, especially the --color-words
item. Once you get familiar with diff.c I suppose you could implement
both in a week (the first probably takes just a day).
-- 
Duy
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: the .git folder

2014-04-20 Thread Kevin
Another way, which wouldn't require environment variables or extra
parameters for each command is moving the .git directory, and replace
it with a file called .git, which has the path to the actual .git
directory.

Git submodules use this feature too.

On Sun, Apr 20, 2014 at 11:49 AM, Duy Nguyen pclo...@gmail.com wrote:
 On Sun, Apr 20, 2014 at 4:13 PM, Miller, Hugh hughmil...@chevron.com wrote:
 Dear Community,

 Is there any way to use .git (e.g., a different set of client commands) 
 that allows the .git folder to be placed in a location away from the actual 
 files being versioned ? For example, can one set environment variables that 
 let the software know where the .git folder is ?

 Try

 git --git-dir=new .git location --work-tree=top work tree location
 some command

 The reason of two arguments instead of one is because .git is also
 used to mark top work tree location, which is now lost after you move
 .git elsewhere. You could also set environment variables GIT_DIR and
 GIT_WORK_TREE, which have the same effect. man git for details.
 --
 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
--
To unsubscribe from this list: send the line 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: Project idea: github-like diff view

2014-04-20 Thread Jeff King
On Sun, Apr 20, 2014 at 04:58:28PM +0700, Duy Nguyen wrote:

 - --color-words within unified diff format, using background color to
 show what part of the line has changed. This is only enabled for
 1-line changes.

See contrib/diff-highlight.

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


[PATCH v2 0/2] peroper align of datetime filed of git-blame

2014-04-20 Thread Jiang Xin
When rewrite time_buf[128] to strbuf, find another bug from the original
implement.  See detail commit log of 1/2.

Jiang Xin (2):
  bugfix: fix broken time_buf paddings for git-blame
  blame: use different blame_date_width for different locale

 builtin/blame.c | 29 +++--
 1 file changed, 23 insertions(+), 6 deletions(-)

-- 
2.0.0.rc0.3.g444188f.dirty

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


[PATCH v2 2/2] blame: use different blame_date_width for different locale

2014-04-20 Thread Jiang Xin
When show date in relative date format for `git blame`, the max display
width of datetime is set as the length of the string Thu Oct 19
16:00:04 2006 -0700 (30 characters long).  But actually the max width
for C locale is only 22 (the length of string x years, xx months ago).
And for other locale, it maybe smaller.  E.g. For Chinese locale, only
needs 16-character width.

Set blame_date_width as the display width of _(4 years, 11 months
ago), so that translators can make the choice.

Signed-off-by: Jiang Xin worldhello@gmail.com
---
 builtin/blame.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/builtin/blame.c b/builtin/blame.c
index 0a0a858..9350ea3 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -2340,7 +2340,15 @@ parse_done:
blame_date_width = sizeof(2006-10-19);
break;
case DATE_RELATIVE:
-   /* normal is used as the fallback for relative */
+   /* TRANSLATORS: what we care about is not the content itself,
+  but the display width of this string.  We use the width of
+  the string as the max width of the datetime in relative
+  format.  For English and many other languages, 4 years,
+  11 months ago is the longest one among 89 seconds ago,
+  89 minites ago, 35 hours ago, 13 days ago, 10 weeks
+  ago, in the future and many others. */
+   blame_date_width = utf8_strwidth(_(4 years, 11 months ago)) + 
1; /* add the null */
+   break;
case DATE_LOCAL:
case DATE_NORMAL:
blame_date_width = sizeof(Thu Oct 19 16:00:04 2006 -0700);
-- 
2.0.0.rc0.3.g444188f.dirty

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


[PATCH v2 1/2] bugfix: fix broken time_buf paddings for git-blame

2014-04-20 Thread Jiang Xin
When `git blame` shows date field in a fixed width (as long as
blame_date_width characters), if time_str shorter than that, add spaces
for padding.  But there are two bugs in the following codes:

memcpy(time_buf, time_str, time_len);
memset(time_buf + time_len, ' ', blame_date_width - time_len);

1. The type of blame_date_width is size_t (unsigned int).  If time_len
   is greater than blame_ate_width, blame_date_width - time_len will
   never be a negative number, but a really big positive number, and
   will cause memory overwrite.

   This bug can be triggered if either l10n message for function
   show_date_relative() in date.c is longer then 30 charcters, then
   `git blame --date relative` may fail.

2. When show blame information with relative time, the UTF-8 characters
   in time_str will break the alignment of columns after the date field.
   This is because the time_buf padding with spaces should have a
   constant display width, not a fixed strlen size.  So we should call
   utf8_strwidth() instead of strlen() for calibration.

Signed-off-by: Jiang Xin worldhello@gmail.com
---
 builtin/blame.c | 19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/builtin/blame.c b/builtin/blame.c
index 88cb799..0a0a858 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -1556,22 +1556,31 @@ static void assign_blame(struct scoreboard *sb, int opt)
 static const char *format_time(unsigned long time, const char *tz_str,
   int show_raw_time)
 {
-   static char time_buf[128];
+   static struct strbuf time_buf = STRBUF_INIT;
 
+   strbuf_reset(time_buf);
if (show_raw_time) {
-   snprintf(time_buf, sizeof(time_buf), %lu %s, time, tz_str);
+   strbuf_addf(time_buf, %lu %s, time, tz_str);
}
else {
const char *time_str;
+   size_t time_width;
int time_len;
int tz;
tz = atoi(tz_str);
time_str = show_date(time, tz, blame_date_mode);
time_len = strlen(time_str);
-   memcpy(time_buf, time_str, time_len);
-   memset(time_buf + time_len, ' ', blame_date_width - time_len);
+   strbuf_add(time_buf, time_str, time_len);
+   /*
+* Add space paddings to time_buf to display a fixed width
+* string, and use time_width for display width calibration.
+*/
+   for (time_width = utf8_strwidth(time_str);
+time_width  blame_date_width;
+time_width++)
+   strbuf_addch(time_buf, ' ');
}
-   return time_buf;
+   return time_buf.buf;
 }
 
 #define OUTPUT_ANNOTATE_COMPAT 001
-- 
2.0.0.rc0.3.g444188f.dirty

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


Re: Our official home page and logo for the Git project

2014-04-20 Thread Felipe Contreras
Stefan Beller wrote:
 So this is really bikeshedding at its finest.

You don't seem to understand what is bikeshedding. The reason a bikeshed is
used as reference is because the primary function of a bikeshed is to store
bikes, and therefore the color of the bikeshed doesn't really matter.

A logo is not a bikeshed, the color does matter. I challenge you to tell a
bride that the she is bikeshedding while choosing the color of the dresses for
her bridemaids.

Sometimes color does matter.

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


Re: [PATCH] git-remote-hg : Enable use of, $GIT_DIR/hg/origin/clone/.hg/hgrc

2014-04-20 Thread Felipe Contreras
Delcypher wrote:
  What is the problem you are trying to solve?
 The problem I was trying to solve is I wanted my authentication
 details to be in a hgrc local to the repository.
 
 The problem is git-remote-hg will parse
 ``.git/hg/origin/clone/.hg/hgrc`` but will ignore any settings in it
 (this seems a little silly).
 You can see that git-remote-hg parses this by placing invalid syntax
 in the file.
 
  Is there a way to test that this
  code is working correctly?
 
 The effects are much more obvious if you use a mercurial repository
 that uses https and then you try to push to it with authentication
 details in ``.git/hg/origin/clone/.hg/hgrc``. For example
 
 [auth]
 cc.prefix = hg.codeplex.com
 cc.username = USERNAME
 cc.password = PASSWORD
 cc.schemes = https
 
 pushing will fail because the authorisation details get completely
 ignored and you will get an exception raised with a stack trace like
 this...
 
 Traceback (most recent call last):
   File /home/dsl11/dev/git-remote-hg/git-remote-hg, line 1254, in module
 sys.exit(main(sys.argv))
   File /home/dsl11/dev/git-remote-hg/git-remote-hg, line 1238, in main
 do_export(parser)
   File /home/dsl11/dev/git-remote-hg/git-remote-hg, line 1119, in do_export
 if not push(parser.repo, peer, parsed_refs, p_revs):
   File /home/dsl11/dev/git-remote-hg/git-remote-hg, line 1007, in push
 ret = push_unsafe(repo, remote, parsed_refs, p_revs)
   File /home/dsl11/dev/git-remote-hg/git-remote-hg, line 990, in push_unsafe
 return remote.unbundle(cg, remoteheads, 'push')
   File /usr/lib/python2.7/site-packages/mercurial/wireproto.py, line
 308, in unbundle
 ret, output = self._callpush(unbundle, cg, heads=heads)
   File /usr/lib/python2.7/site-packages/mercurial/httppeer.py, line
 201, in _callpush
 r = self._call(cmd, data=fp, headers=headers, **args)
   File /usr/lib/python2.7/site-packages/mercurial/httppeer.py, line
 171, in _call
 fp = self._callstream(cmd, **args)
   File /usr/lib/python2.7/site-packages/mercurial/httppeer.py, line
 118, in _callstream
 resp = self.urlopener.open(req)
   File /usr/lib/python2.7/urllib2.py, line 410, in open
 response = meth(req, response)
   File /usr/lib/python2.7/urllib2.py, line 523, in http_response
 'http', request, response, code, msg, hdrs)
   File /usr/lib/python2.7/urllib2.py, line 442, in error
 result = self._call_chain(*args)
   File /usr/lib/python2.7/urllib2.py, line 382, in _call_chain
 result = func(*args)
   File /usr/lib/python2.7/urllib2.py, line 897, in http_error_401
 url, req, headers)
   File /usr/lib/python2.7/site-packages/mercurial/url.py, line 436,
 in http_error_auth_reqed
 self, auth_header, host, req, headers)
   File /usr/lib/python2.7/urllib2.py, line 872, in http_error_auth_reqed
 response = self.retry_http_basic_auth(host, req, realm)
   File /usr/lib/python2.7/urllib2.py, line 878, in retry_http_basic_auth
 user, pw = self.passwd.find_user_password(realm, host)
   File /usr/lib/python2.7/site-packages/mercurial/url.py, line 36,
 in find_user_password
 raise util.Abort(_('http authorization required'))
 mercurial.error.Abort: http authorization required
 
 
 However, if you don't have a repository to hand you could also do the
 following to observe the settings in the repository's hgrc being
 respected
 
 1. Clone a repository
 $ git clone hg::https://hg.codeplex.com/boogie
 
 2. Add setting to ``.git/hg/origin/clone/.hg/hgrc``
 
 [ui]
 quiet = True
 
 3. With the current of git-remote-hg, when you do a pull you see
 
 $ git pull
 searching for changes
 no changes found
 Already up-to-date.
 
 You can see that quiet is **not** being respected. If use my patch
 to git-remote-hg and run again you see
 
 
 $ git pull
 Already up-to-date.
 
 which shows quiet being respected.

This is what I get:

% git pull  
/tmp/boogie[master] nysa
searching for changes
no changes found
Already up-to-date.
 % cat  .git/hg/origin/clone/.hg/hgrc EOF
[ui]
quiet = True
EOF
 % git pull 
 /tmp/boogie[master] nysa
Already up-to-date.

So clearly there is something different on my side.

What version of Mercurial are you using?

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


RE: [PATCH 0/5] fc/transport-helper-sync-error-fix rebased

2014-04-20 Thread Felipe Contreras
Junio C Hamano wrote:
 As I have said in the recent What's cooking reports, the original
 posted here were based on older codebase and needed to be rebased,
 but it had some conflicts and I wanted to see the result double
 checked by the original author before we can merge it to 'next',
 cooked there and hopefully merged to 'master' before tagging -rc1.
 
 So here is the series that has been queued in 'pu' for the past
 several days.
 
 Felipe, can you double check it?

These patches don't help much, I did and interdiff with my own fixes and this
is the result:

diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index 284bf3f..aa3e223 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -221,13 +221,16 @@ test_expect_success 'push update refs failure' '
 '
 
 clean_mark () {
-   cut -f 2 -d ' ' $1 | git cat-file --batch-check | grep commit | sort  
$(basename $1)
+   cut -f 2 -d ' ' $1 |
+   git cat-file --batch-check |
+   grep commit |
+   sort $(basename $1)
 }
 
 cmp_marks () {
test_when_finished rm -rf git.marks testgit.marks 
-   clean_mark .git/testgit/$1/git.marks 
-   clean_mark .git/testgit/$1/testgit.marks 
+   clean_mark .git/testgit/$1/git.marks 
+   clean_mark .git/testgit/$1/testgit.marks 
test_cmp git.marks testgit.marks
 }
 
@@ -244,7 +247,7 @@ test_expect_success 'proper failure checks for fetching' '
 test_expect_success 'proper failure checks for pushing' '
(cd local 
git checkout -b crash master 
-   echo crash  file 
+   echo crash file 
git commit -a -m crash 
test_must_fail env GIT_REMOTE_TESTGIT_FAILURE=1 git push --all 
cmp_marks origin

I don't like it, but it's OK.

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


[PATCH] t5801 (remote-helpers): cleanup environment sets

2014-04-20 Thread Felipe Contreras
Commit 512477b (tests: use env to run commands with temporary env-var
settings) missed some variables in the remote-helpers test. Also
standardize these.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 t/t5801-remote-helpers.sh | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index 25fd2e7..42d1c66 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -212,19 +212,17 @@ test_expect_success 'push update refs failure' '
echo update fail file 
git commit -a -m update fail 
git rev-parse --verify testgit/origin/heads/update expect 
-   GIT_REMOTE_TESTGIT_PUSH_ERROR=non-fast forward 
-   export GIT_REMOTE_TESTGIT_PUSH_ERROR 
-   test_expect_code 1 git push origin update 
+   test_expect_code 1 env GIT_REMOTE_TESTGIT_FAILURE=non-fast forward \
+   git push origin update 
git rev-parse --verify testgit/origin/heads/update actual 
test_cmp expect actual
)
 '
 
 test_expect_success 'proper failure checks for fetching' '
-   (GIT_REMOTE_TESTGIT_FAILURE=1 
-   export GIT_REMOTE_TESTGIT_FAILURE 
-   cd local 
-   test_must_fail git fetch 2 error 
+   (cd local 
+   test_must_fail env GIT_REMOTE_TESTGIT_FAILURE=1 \
+   git fetch 2 error 
cat error 
grep -q Error while running fast-import error
)
@@ -232,7 +230,8 @@ test_expect_success 'proper failure checks for fetching' '
 
 test_expect_success 'proper failure checks for pushing' '
(cd local 
-   test_must_fail env GIT_REMOTE_TESTGIT_FAILURE=1 git push --all
+   test_must_fail env GIT_REMOTE_TESTGIT_FAILURE=1 \
+   git push --all
)
 '
 
-- 
1.9.1+fc3.9.gc73078e

--
To unsubscribe from this list: send the line 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/8] transport-helper: refspec support

2014-04-20 Thread Felipe Contreras
Hi,

Here are the patches that allow transport helpers to be completely transparent
by adding the remaining missing feature: pushing refspecs and deleting branches
(old:new :delete).

These were already sent before, but dropped in later patch series because Junio
didn't like some name.

Apparently Git v2.0 is already advertising this feature, but it's missing the
actual patches.

Felipe Contreras (8):
  fast-export: improve argument parsing
  fast-export: add new --refspec option
  transport-helper: add support for old:new refspec
  transport-helper: add support to push symbolic refs
  fast-import: add support to delete refs
  fast-export: add support to delete refs
  transport-helper: add support to delete branches
  transport-helper: remove unnecessary strbuf resets

 Documentation/git-fast-export.txt |  4 
 Documentation/git-fast-import.txt |  3 +++
 builtin/fast-export.c | 49 ++-
 fast-import.c | 13 ---
 t/t5801-remote-helpers.sh | 18 +-
 t/t9300-fast-import.sh| 18 ++
 t/t9350-fast-export.sh| 18 ++
 transport-helper.c| 32 ++---
 8 files changed, 141 insertions(+), 14 deletions(-)

-- 
1.9.1+fc3.9.gc73078e

--
To unsubscribe from this list: send the line 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/8] fast-export: improve argument parsing

2014-04-20 Thread Felipe Contreras
We don't want to pass arguments specific to fast-export to
setup_revisions.

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

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

--
To unsubscribe from this list: send the line 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/8] fast-export: add new --refspec option

2014-04-20 Thread Felipe Contreras
So that we can convert the exported ref names.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
Signed-off-by: Junio C Hamano gits...@pobox.com
---
 Documentation/git-fast-export.txt |  4 
 builtin/fast-export.c | 32 
 t/t9350-fast-export.sh|  7 +++
 3 files changed, 43 insertions(+)

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

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to 

[PATCH 4/8] transport-helper: add support to push symbolic refs

2014-04-20 Thread Felipe Contreras
For example 'HEAD'.

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

diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index 52b3c99..8288669 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -94,6 +94,14 @@ test_expect_success 'push new branch with old:new refspec' '
compare_refs local HEAD server refs/heads/new-refspec
 '
 
+test_expect_success 'push new branch with HEAD:new refspec' '
+   (cd local 
+git checkout new-name
+git push origin HEAD:new-refspec-2
+   ) 
+   compare_refs local HEAD server refs/heads/new-refspec-2
+'
+
 test_expect_success 'forced push' '
(cd local 
git checkout -b force-test 
diff --git a/transport-helper.c b/transport-helper.c
index 3f45c47..f74eb57 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -896,7 +896,16 @@ static int push_refs_with_export(struct transport 
*transport,
if (ref-peer_ref) {
if (strcmp(ref-name, ref-peer_ref-name)) {
struct strbuf buf = STRBUF_INIT;
-   strbuf_addf(buf, %s:%s, ref-peer_ref-name, 
ref-name);
+   const char *name;
+   int flag;
+
+   /* Follow symbolic refs (mainly for HEAD). */
+   name = resolve_ref_unsafe(ref-peer_ref-name, 
sha1, 1, flag);
+   if (!name || !(flag  REF_ISSYMREF))
+   name = ref-peer_ref-name;
+
+   strbuf_addf(buf, %s:%s, name, ref-name);
+
string_list_append(revlist_args, --refspec);
string_list_append(revlist_args, buf.buf);
strbuf_release(buf);
-- 
1.9.1+fc3.9.gc73078e

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


[PATCH 6/8] fast-export: add support to delete refs

2014-04-20 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
Signed-off-by: Junio C Hamano gits...@pobox.com
---
 builtin/fast-export.c  | 14 ++
 t/t9350-fast-export.sh | 11 +++
 2 files changed, 25 insertions(+)

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

--
To unsubscribe from this list: send the line 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 8/8] transport-helper: remove unnecessary strbuf resets

2014-04-20 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 transport-helper.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/transport-helper.c b/transport-helper.c
index 36fbf93..a90094d 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -876,8 +876,6 @@ static int push_refs_with_export(struct transport 
*transport,
 
write_constant(helper-in, export\n);
 
-   strbuf_reset(buf);
-
for (ref = remote_refs; ref; ref = ref-next) {
char *private;
unsigned char sha1[20];
@@ -892,8 +890,6 @@ static int push_refs_with_export(struct transport 
*transport,
 
if (ref-peer_ref) {
if (strcmp(ref-name, ref-peer_ref-name)) {
-   struct strbuf buf = STRBUF_INIT;
-
if (!ref-deletion) {
const char *name;
int flag;
-- 
1.9.1+fc3.9.gc73078e

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


[PATCH 3/8] transport-helper: add support for old:new refspec

2014-04-20 Thread Felipe Contreras
By using fast-export's new --refspec option.

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

diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index 25fd2e7..52b3c99 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -87,7 +87,7 @@ test_expect_success 'push new branch by name' '
compare_refs local HEAD server refs/heads/new-name
 '
 
-test_expect_failure 'push new branch with old:new refspec' '
+test_expect_success 'push new branch with old:new refspec' '
(cd local 
 git push origin new-name:new-refspec
) 
diff --git a/transport-helper.c b/transport-helper.c
index 86e1679..3f45c47 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -856,7 +856,7 @@ static int push_refs_with_export(struct transport 
*transport,
struct ref *ref;
struct child_process *helper, exporter;
struct helper_data *data = transport-data;
-   struct string_list revlist_args = STRING_LIST_INIT_NODUP;
+   struct string_list revlist_args = STRING_LIST_INIT_DUP;
struct strbuf buf = STRBUF_INIT;
 
if (!data-refspecs)
@@ -894,8 +894,13 @@ static int push_refs_with_export(struct transport 
*transport,
free(private);
 
if (ref-peer_ref) {
-   if (strcmp(ref-peer_ref-name, ref-name))
-   die(remote-helpers do not support old:new 
syntax);
+   if (strcmp(ref-name, ref-peer_ref-name)) {
+   struct strbuf buf = STRBUF_INIT;
+   strbuf_addf(buf, %s:%s, ref-peer_ref-name, 
ref-name);
+   string_list_append(revlist_args, --refspec);
+   string_list_append(revlist_args, buf.buf);
+   strbuf_release(buf);
+   }
string_list_append(revlist_args, ref-peer_ref-name);
}
}
@@ -903,6 +908,8 @@ static int push_refs_with_export(struct transport 
*transport,
if (get_exporter(transport, exporter, revlist_args))
die(Couldn't run fast-export);
 
+   string_list_clear(revlist_args, 1);
+
if (finish_command(exporter))
die(Error while running fast-export);
push_update_refs_status(data, remote_refs, flags);
-- 
1.9.1+fc3.9.gc73078e

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


[PATCH 5/8] fast-import: add support to delete refs

2014-04-20 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
Signed-off-by: Junio C Hamano gits...@pobox.com
---
 Documentation/git-fast-import.txt |  3 +++
 fast-import.c | 13 ++---
 t/t9300-fast-import.sh| 18 ++
 3 files changed, 31 insertions(+), 3 deletions(-)

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

--
To unsubscribe from this list: send the line 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 7/8] transport-helper: add support to delete branches

2014-04-20 Thread Felipe Contreras
For remote-helpers that use 'export' to push.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
Signed-off-by: Junio C Hamano gits...@pobox.com
---
 t/t5801-remote-helpers.sh |  8 
 transport-helper.c| 24 +---
 2 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index 8288669..aec924b 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -102,6 +102,14 @@ test_expect_success 'push new branch with HEAD:new 
refspec' '
compare_refs local HEAD server refs/heads/new-refspec-2
 '
 
+test_expect_success 'push delete branch' '
+   (cd local 
+git push origin :new-name
+   ) 
+   test_must_fail git --git-dir=server/.git \
+rev-parse --verify refs/heads/new-name
+'
+
 test_expect_success 'forced push' '
(cd local 
git checkout -b force-test 
diff --git a/transport-helper.c b/transport-helper.c
index f74eb57..36fbf93 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -882,9 +882,6 @@ static int push_refs_with_export(struct transport 
*transport,
char *private;
unsigned char sha1[20];
 
-   if (ref-deletion)
-   die(remote-helpers do not support ref deletion);
-
private = apply_refspecs(data-refspecs, data-refspec_nr, 
ref-name);
if (private  !get_sha1(private, sha1)) {
strbuf_addf(buf, ^%s, private);
@@ -896,21 +893,26 @@ static int push_refs_with_export(struct transport 
*transport,
if (ref-peer_ref) {
if (strcmp(ref-name, ref-peer_ref-name)) {
struct strbuf buf = STRBUF_INIT;
-   const char *name;
-   int flag;
 
-   /* Follow symbolic refs (mainly for HEAD). */
-   name = resolve_ref_unsafe(ref-peer_ref-name, 
sha1, 1, flag);
-   if (!name || !(flag  REF_ISSYMREF))
-   name = ref-peer_ref-name;
+   if (!ref-deletion) {
+   const char *name;
+   int flag;
+
+   /* Follow symbolic refs (mainly for 
HEAD). */
+   name = 
resolve_ref_unsafe(ref-peer_ref-name, sha1, 1, flag);
+   if (!name || !(flag  REF_ISSYMREF))
+   name = ref-peer_ref-name;
 
-   strbuf_addf(buf, %s:%s, name, ref-name);
+   strbuf_addf(buf, %s:%s, name, 
ref-name);
+   } else
+   strbuf_addf(buf, :%s, ref-name);
 
string_list_append(revlist_args, --refspec);
string_list_append(revlist_args, buf.buf);
strbuf_release(buf);
}
-   string_list_append(revlist_args, ref-peer_ref-name);
+   if (!ref-deletion)
+   string_list_append(revlist_args, 
ref-peer_ref-name);
}
}
 
-- 
1.9.1+fc3.9.gc73078e

--
To unsubscribe from this list: send the line 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: [ANNOUNCE] Git v2.0.0-rc0

2014-04-20 Thread Felipe Contreras
Junio C Hamano wrote:
  * transport-helper, fast-import and fast-export have been updated to
allow the ref mapping and ref deletion in a way similar to the
natively supported transports.

Have they?

% git --version
git version 2.0.0.rc0
% git push origin origin master:foo 
   /tmp/test[master] nysa
searching for changes
no changes found
fatal: remote-helpers do not support old:new syntax
ERROR: unhandled export command:

I think you are missing the patches which I just resent[1].

[1] http://article.gmane.org/gmane.comp.version-control.git/246558

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


[PATCH v4 1/8] t5516 (fetch-push): fix test restoration

2014-04-20 Thread Felipe Contreras
We shouldn't modify the commits; it screws the following tests.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 t/t5516-fetch-push.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 67e0ab3..f4cf0db 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -1261,6 +1261,8 @@ test_expect_success 'push --follow-tag only pushes 
relevant tags' '
 '
 
 test_expect_success 'push --no-thin must produce non-thin pack' '
+   test_when_finished git reset --hard v1.0 
+
cat path1 \EOF 
 keep base version of path1 big enough, compared to the new changes
 later, in order to pass size heuristics in
-- 
1.9.1+fc3.9.gc73078e

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


[PATCH v4 0/8] Introduce publish tracking branch

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

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

So, let's introduce the concept of a publish branch (similar to upstream),
which is used by push to determine the branch to push to, if the user hasn't
specified any manually, and overrides other configurations, such as
(push.default, and remote.$name.push).

This patch series adds:

 1) git push --set-publish
 2) git branch --set-publish
 3) git branch -vv # uses and shows the publish branch when configured
 4) @{publish} and @{p} marks
 5) branch.$name.{push,pushremote} configurations

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

The publish branch is used instead of the upstream branch for tracking
information in 'git branch --vv' and 'git status' if present, otherwise there
are no changes (upstream is used).

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

Changes since v3:

 * Fix a possible crash
 * Improve tests so they work with newer push.default

diff --git a/builtin/push.c b/builtin/push.c
index 172e843..1beed0c 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -443,8 +443,8 @@ static int do_push(const char *repo, int flags)
if (!refspec  !(flags  TRANSPORT_PUSH_ALL)) {
struct branch *branch = branch_get(NULL);
/* Is there a publish branch */
-   if (branch-pushremote_name  !strcmp(remote-name, 
branch-pushremote_name) 
-   branch  branch-push_name) {
+   if (branch  branch-pushremote_name  !strcmp(remote-name, 
branch-pushremote_name) 
+   branch-push_name) {
struct strbuf refspec = STRBUF_INIT;
strbuf_addf(refspec, %s:%s, branch-name, 
branch-push_name);
add_refspec(refspec.buf);
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index f9c528d..80a00e3 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -1279,63 +1279,49 @@ EOF
git push --no-thin --receive-pack=$rcvpck no-thin/.git 
refs/heads/master:refs/heads/foo
 '
 
-test_expect_success 'push with publish branch' '
+mk_publish_test () {
mk_test up_repo heads/master 
mk_test down_repo heads/master 
test_config remote.up.url up_repo 
test_config remote.down.url down_repo 
test_config branch.master.pushremote down 
test_config branch.master.push for-john 
+   test_config branch.master.remote up 
+   test_config branch.master.merge master
+}
+
+test_expect_success 'push with publish branch' '
+   mk_publish_test 
git push 
check_push_result up_repo $the_first_commit heads/master 
check_push_result down_repo $the_commit heads/for-john
 '
 
 test_expect_success 'push with publish branch for different remote' '
-   mk_test up_repo heads/master 
-   mk_test down_repo heads/master 
-   test_config remote.up.url up_repo 
-   test_config remote.down.url down_repo 
-   test_config branch.master.pushremote down 
-   test_config branch.master.push for-john 
+   mk_publish_test 
git push up 
check_push_result up_repo $the_commit heads/master 
check_push_result down_repo $the_first_commit heads/master
 '
 
 test_expect_success 'push with publish branch with pushdefault' '
-   mk_test up_repo heads/master 
-   mk_test down_repo heads/master 
-   test_config remote.up.url up_repo 
-   test_config remote.down.url down_repo 
+   mk_publish_test 
test_config remote.pushdefault up 
-   test_config branch.master.pushremote down 
-   test_config branch.master.push for-john 
git push 
check_push_result up_repo $the_first_commit heads/master 
check_push_result down_repo $the_commit heads/for-john
 '
 
 test_expect_success 'push with publish branch with remote refspec' '
-   mk_test up_repo heads/master 
-   mk_test down_repo 

[PATCH v4 8/8] sha1_name: add support for @{publish} marks

2014-04-20 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 Documentation/revisions.txt |  4 
 sha1_name.c | 49 -
 t/t1508-at-combinations.sh  |  5 +
 3 files changed, 40 insertions(+), 18 deletions(-)

diff --git a/Documentation/revisions.txt b/Documentation/revisions.txt
index 5a286d0..fd01cb4 100644
--- a/Documentation/revisions.txt
+++ b/Documentation/revisions.txt
@@ -96,6 +96,10 @@ some output processing may assume ref names in UTF-8.
   refers to the branch that the branch specified by branchname is set to build 
on
   top of.  A missing branchname defaults to the current one.
 
+'branchname@\{publish\}', e.g. 'master@\{publish\}', '@\{p\}'::
+  The suffix '@\{publish\}' to a branchname refers to the remote branch to
+  push to. A missing branchname defaults to the current one.
+
 'rev{caret}', e.g. 'HEAD{caret}, v1.5.1{caret}0'::
   A suffix '{caret}' to a revision parameter means the first parent of
   that commit object.  '{caret}n' means the nth parent (i.e.
diff --git a/sha1_name.c b/sha1_name.c
index aa3f3e0..a36852d 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -415,9 +415,9 @@ static int ambiguous_path(const char *path, int len)
return slash;
 }
 
-static inline int upstream_mark(const char *string, int len)
+static inline int tracking_mark(const char *string, int len)
 {
-   const char *suffix[] = { upstream, u };
+   const char *suffix[] = { upstream, u, publish, p };
int i;
 
for (i = 0; i  ARRAY_SIZE(suffix); i++) {
@@ -475,7 +475,7 @@ static int get_sha1_basic(const char *str, int len, 
unsigned char *sha1)
nth_prior = 1;
continue;
}
-   if (!upstream_mark(str + at + 2, len - at - 3)) 
{
+   if (!tracking_mark(str + at + 2, len - at - 3)) 
{
reflog_len = (len-1) - (at+2);
len = at;
}
@@ -1057,10 +1057,11 @@ static void set_shortened_ref(struct strbuf *buf, const 
char *ref)
free(s);
 }
 
-static const char *get_upstream_branch(const char *name_buf, int len)
+static const char *get_tracking_branch(const char *name_buf, int len, char 
type)
 {
char *name = xstrndup(name_buf, len);
struct branch *branch = branch_get(*name ? name : NULL);
+   char *tracking = NULL;
 
/*
 * Upstream can be NULL only if branch refers to HEAD and HEAD
@@ -1068,23 +1069,35 @@ static const char *get_upstream_branch(const char 
*name_buf, int len)
 */
if (!branch)
die(_(HEAD does not point to a branch));
-   if (!branch-merge || !branch-merge[0]-dst) {
-   if (!ref_exists(branch-refname))
-   die(_(No such branch: '%s'), name);
-   if (!branch-merge) {
-   die(_(No upstream configured for branch '%s'),
-   branch-name);
+   switch (type) {
+   case 'u':
+   if (!branch-merge || !branch-merge[0]-dst) {
+   if (!ref_exists(branch-refname))
+   die(_(No such branch: '%s'), name);
+   if (!branch-merge) {
+   die(_(No upstream configured for branch '%s'),
+   branch-name);
+   }
+   die(
+   _(Upstream branch '%s' not stored as a 
remote-tracking branch),
+   branch-merge[0]-src);
+   }
+   tracking = branch-merge[0]-dst;
+   break;
+   case 'p':
+   if (!branch-push.dst) {
+   die(_(No publish configured for branch '%s'),
+   branch-name);
}
-   die(
-   _(Upstream branch '%s' not stored as a remote-tracking 
branch),
-   branch-merge[0]-src);
+   tracking = branch-push.dst;
+   break;
}
free(name);
 
-   return branch-merge[0]-dst;
+   return tracking;
 }
 
-static int interpret_upstream_mark(const char *name, int namelen,
+static int interpret_tracking_mark(const char *name, int namelen,
   int at, struct strbuf *buf)
 {
int len;
@@ -1092,14 +1105,14 @@ static int interpret_upstream_mark(const char *name, 
int namelen,
if (name[at + 1] != '{' || name[namelen - 1] != '}')
return -1;
 
-   len = upstream_mark(name + at + 2, namelen - at - 3);
+   len = tracking_mark(name + at + 2, namelen - at - 3);
if (!len)
return -1;
 
if (memchr(name, ':', at))
return -1;
 
-   

[PATCH v4 2/8] Add concept of 'publish' branch

2014-04-20 Thread Felipe Contreras
The publish branch is the branch the user wants to push to, akin to the
upstream branch, which is the branch the user wants to use as a
baseline. It overrides other configurations, such as push.default, and
remote.name.push.

The upstream branch is:

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

The publish branch is:

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

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 Documentation/config.txt |  7 +++
 builtin/push.c   |  9 -
 remote.c | 34 --
 remote.h |  4 
 t/t5516-fetch-push.sh| 48 
 5 files changed, 95 insertions(+), 7 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 5f4d793..1569353 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -764,6 +764,13 @@ branch.name.mergeoptions::
option values containing whitespace characters are currently not
supported.
 
+branch.name.push::
+   Defines, together with branch.name.pushremote, the publish branch for
+   the given branch. It tells 'git push' which branch to push to, and
+   overrides any other configurations, such as push.default. It also tells
+   commands such as 'git status' and 'git branch' which remote branch to
+   use for tracking information (commits ahead and behind).
+
 branch.name.rebase::
When true, rebase the branch name on top of the fetched branch,
instead of merging the default branch from the default remote when
diff --git a/builtin/push.c b/builtin/push.c
index 0e50ddb..fe48c95 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -441,7 +441,14 @@ static int do_push(const char *repo, int flags)
}
 
if (!refspec  !(flags  TRANSPORT_PUSH_ALL)) {
-   if (remote-push_refspec_nr) {
+   struct branch *branch = branch_get(NULL);
+   /* Is there a publish branch */
+   if (branch  branch-pushremote_name  !strcmp(remote-name, 
branch-pushremote_name) 
+   branch-push_name) {
+   struct strbuf refspec = STRBUF_INIT;
+   strbuf_addf(refspec, %s:%s, branch-name, 
branch-push_name);
+   add_refspec(refspec.buf);
+   } else if (remote-push_refspec_nr) {
refspec = remote-push_refspec;
refspec_nr = remote-push_refspec_nr;
} else if (!(flags  TRANSPORT_PUSH_MIRROR))
diff --git a/remote.c b/remote.c
index 5f63d55..eda6192 100644
--- a/remote.c
+++ b/remote.c
@@ -352,13 +352,17 @@ static int handle_config(const char *key, const char 
*value, void *cb)
explicit_default_remote_name = 1;
}
} else if (!strcmp(subkey, .pushremote)) {
+   if (git_config_string(branch-pushremote_name, key, 
value))
+   return -1;
if (branch == current_branch)
-   if (git_config_string(branch_pushremote_name, 
key, value))
-   return -1;
+   branch_pushremote_name = 
xstrdup(branch-pushremote_name);
} else if (!strcmp(subkey, .merge)) {
if (!value)
return config_error_nonbool(key);
add_merge(branch, xstrdup(value));
+   } else if (!strcmp(subkey, .push)) {
+   if (git_config_string(branch-push_name, key, value))
+   return -1;
}
return 0;
}
@@ -1562,6 +1566,14 @@ struct branch *branch_get(const char *name)
}
}
}
+   if (ret  ret-pushremote_name  ret-push_name) {
+   struct remote *pushremote;
+   pushremote = pushremote_get(ret-pushremote_name);
+   ret-push.src = xstrdup(ret-push_name);
+   if (remote_find_tracking(pushremote, ret-push)
+!strcmp(ret-pushremote_name, .))
+   ret-push.dst = xstrdup(ret-push_name);
+   }
return ret;
 }
 
@@ -1771,6 +1783,15 @@ int ref_newer(const unsigned char *new_sha1, const 
unsigned char *old_sha1)
return found;
 }
 
+static char *get_base(struct branch *branch)
+{
+   if (branch-push.dst)
+   return branch-push.dst;
+   if (branch-merge  branch-merge[0]  branch-merge[0]-dst)
+   return branch-merge[0]-dst;
+   return NULL;
+}
+
 /*
  * Compare a branch with its upstream, and save their differences (number
  * of commits) in *num_ours and *num_theirs.
@@ -1788,12 +1809,13 @@ int stat_tracking_info(struct branch *branch, int 
*num_ours, int *num_theirs)
int rev_argc;
 
/* Cannot stat 

[PATCH v4 4/8] push: add --set-publish option

2014-04-20 Thread Felipe Contreras
To setup publish tracking branch, like 'git branch --set-publish'.

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

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

[PATCH v4 3/8] branch: add --set-publish-to option

2014-04-20 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 Documentation/git-branch.txt | 11 +++
 branch.c | 44 +
 branch.h |  2 ++
 builtin/branch.c | 57 ++---
 t/t3200-branch.sh| 76 
 5 files changed, 185 insertions(+), 5 deletions(-)

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

[PATCH v4 5/8] branch: display publish branch

2014-04-20 Thread Felipe Contreras
It does it along the upstream branch, if any.

* publish ... [master, gh/publish: ahead 1] ...
  master  ... [master, gh/master] ...

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

diff --git a/builtin/branch.c b/builtin/branch.c
index 17773d7..e0a8d0a 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -42,6 +42,7 @@ static char branch_colors[][COLOR_MAXLEN] = {
GIT_COLOR_NORMAL,   /* LOCAL */
GIT_COLOR_GREEN,/* CURRENT */
GIT_COLOR_BLUE, /* UPSTREAM */
+   GIT_COLOR_YELLOW,   /* PUBLISH */
 };
 enum color_branch {
BRANCH_COLOR_RESET = 0,
@@ -49,7 +50,8 @@ enum color_branch {
BRANCH_COLOR_REMOTE = 2,
BRANCH_COLOR_LOCAL = 3,
BRANCH_COLOR_CURRENT = 4,
-   BRANCH_COLOR_UPSTREAM = 5
+   BRANCH_COLOR_UPSTREAM = 5,
+   BRANCH_COLOR_PUBLISH = 6
 };
 
 static enum merge_filter {
@@ -76,6 +78,8 @@ static int parse_branch_color_slot(const char *var, int ofs)
return BRANCH_COLOR_CURRENT;
if (!strcasecmp(var+ofs, upstream))
return BRANCH_COLOR_UPSTREAM;
+   if (!strcasecmp(var+ofs, publish))
+   return BRANCH_COLOR_PUBLISH;
return -1;
 }
 
@@ -448,6 +452,17 @@ static void fill_tracking_info(struct strbuf *stat, const 
char *branch_name,
else
strbuf_addstr(fancy, ref);
}
+   if (branch-push.dst) {
+   ref = shorten_unambiguous_ref(branch-push.dst, 0);
+   if (fancy.len)
+   strbuf_addstr(fancy, , );
+   if (want_color(branch_use_color))
+   strbuf_addf(fancy, %s%s%s,
+   branch_get_color(BRANCH_COLOR_PUBLISH),
+   ref, 
branch_get_color(BRANCH_COLOR_RESET));
+   else
+   strbuf_addstr(fancy, ref);
+   }
 
if (upstream_is_gone) {
if (show_upstream_ref)
diff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh
index 7ac8fd0..8b9ef63 100755
--- a/t/t6040-tracking-info.sh
+++ b/t/t6040-tracking-info.sh
@@ -33,7 +33,8 @@ test_expect_success setup '
git checkout -b b5 --track brokenbase 
advance g 
git branch -d brokenbase 
-   git checkout -b b6 origin
+   git checkout -b b6 origin 
+   git branch --set-publish origin/master b6
) 
git checkout -b follower --track master 
advance h
@@ -64,7 +65,7 @@ b2 [origin/master: ahead 1, behind 1] d
 b3 [origin/master: behind 1] b
 b4 [origin/master: ahead 2] f
 b5 [brokenbase: gone] g
-b6 [origin/master] c
+b6 [origin/master, origin/master] c
 EOF
 
 test_expect_success 'branch -vv' '
-- 
1.9.1+fc3.9.gc73078e

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


[PATCH v4 6/8] sha1_name: cleanup interpret_branch_name()

2014-04-20 Thread Felipe Contreras
The 'upstream' variable doesn't hold an upstream, but a branch, so
make it clearer.

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

diff --git a/sha1_name.c b/sha1_name.c
index 6fca869..906f09d 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -1057,31 +1057,31 @@ static void set_shortened_ref(struct strbuf *buf, const 
char *ref)
free(s);
 }
 
-static const char *get_upstream_branch(const char *branch_buf, int len)
+static const char *get_upstream_branch(const char *name_buf, int len)
 {
-   char *branch = xstrndup(branch_buf, len);
-   struct branch *upstream = branch_get(*branch ? branch : NULL);
+   char *name = xstrndup(name_buf, len);
+   struct branch *branch = branch_get(*name ? name : NULL);
 
/*
 * Upstream can be NULL only if branch refers to HEAD and HEAD
 * points to something different than a branch.
 */
-   if (!upstream)
+   if (!branch)
die(_(HEAD does not point to a branch));
-   if (!upstream-merge || !upstream-merge[0]-dst) {
-   if (!ref_exists(upstream-refname))
-   die(_(No such branch: '%s'), branch);
-   if (!upstream-merge) {
+   if (!branch-merge || !branch-merge[0]-dst) {
+   if (!ref_exists(branch-refname))
+   die(_(No such branch: '%s'), name);
+   if (!branch-merge) {
die(_(No upstream configured for branch '%s'),
-   upstream-name);
+   branch-name);
}
die(
_(Upstream branch '%s' not stored as a remote-tracking 
branch),
-   upstream-merge[0]-src);
+   branch-merge[0]-src);
}
-   free(branch);
+   free(name);
 
-   return upstream-merge[0]-dst;
+   return branch-merge[0]-dst;
 }
 
 static int interpret_upstream_mark(const char *name, int namelen,
-- 
1.9.1+fc3.9.gc73078e

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


[PATCH v4 7/8] sha1_name: simplify track finding

2014-04-20 Thread Felipe Contreras
It's more efficient to check for the braces first.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 sha1_name.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/sha1_name.c b/sha1_name.c
index 906f09d..aa3f3e0 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -417,7 +417,7 @@ static int ambiguous_path(const char *path, int len)
 
 static inline int upstream_mark(const char *string, int len)
 {
-   const char *suffix[] = { @{upstream}, @{u} };
+   const char *suffix[] = { upstream, u };
int i;
 
for (i = 0; i  ARRAY_SIZE(suffix); i++) {
@@ -475,7 +475,7 @@ static int get_sha1_basic(const char *str, int len, 
unsigned char *sha1)
nth_prior = 1;
continue;
}
-   if (!upstream_mark(str + at, len - at)) {
+   if (!upstream_mark(str + at + 2, len - at - 3)) 
{
reflog_len = (len-1) - (at+2);
len = at;
}
@@ -1089,7 +1089,10 @@ static int interpret_upstream_mark(const char *name, int 
namelen,
 {
int len;
 
-   len = upstream_mark(name + at, namelen - at);
+   if (name[at + 1] != '{' || name[namelen - 1] != '}')
+   return -1;
+
+   len = upstream_mark(name + at + 2, namelen - at - 3);
if (!len)
return -1;
 
@@ -1097,7 +1100,7 @@ static int interpret_upstream_mark(const char *name, int 
namelen,
return -1;
 
set_shortened_ref(buf, get_upstream_branch(name, at));
-   return len + at;
+   return len + at + 3;
 }
 
 /*
-- 
1.9.1+fc3.9.gc73078e

--
To unsubscribe from this list: send the line 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] git-remote-hg : Enable use of, $GIT_DIR/hg/origin/clone/.hg/hgrc

2014-04-20 Thread Delcypher
 What version of Mercurial are you using?

$ hg --version

Mercurial Distributed SCM (version 2.9.2)
(see http://mercurial.selenic.com for more information)

Copyright (C) 2005-2014 Matt Mackall and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--
To unsubscribe from this list: send the line 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] git-remote-hg : Enable use of, $GIT_DIR/hg/origin/clone/.hg/hgrc

2014-04-20 Thread Felipe Contreras
Delcypher wrote:
  What version of Mercurial are you using?
 
 $ hg --version
 
 Mercurial Distributed SCM (version 2.9.2)

Same as me. And which version of git-remote-hg are you using?

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


Re: [PATCH v2 1/2] bugfix: fix broken time_buf paddings for git-blame

2014-04-20 Thread Eric Sunshine
On Sun, Apr 20, 2014 at 12:13 PM, Jiang Xin worldhello@gmail.com wrote:
 When `git blame` shows date field in a fixed width (as long as

s/fixed width/fixed-width/

s/long/wide/ would read a bit better.

 blame_date_width characters), if time_str shorter than that, add spaces

s/shorter/is shorter/
s/add/it adds/

 for padding.  But there are two bugs in the following codes:

 memcpy(time_buf, time_str, time_len);
 memset(time_buf + time_len, ' ', blame_date_width - time_len);

 1. The type of blame_date_width is size_t (unsigned int).  If time_len

s/(unsigned int)/, which is unsigned/

is greater than blame_ate_width, blame_date_width - time_len will

s/_ate/_date/

never be a negative number, but a really big positive number, and
will cause memory overwrite.

This bug can be triggered if either l10n message for function
show_date_relative() in date.c is longer then 30 charcters, then

s/then 30/than 30/
s/charcters/characters/

`git blame --date relative` may fail.

 2. When show blame information with relative time, the UTF-8 characters
in time_str will break the alignment of columns after the date field.
This is because the time_buf padding with spaces should have a
constant display width, not a fixed strlen size.  So we should call
utf8_strwidth() instead of strlen() for calibration.

 Signed-off-by: Jiang Xin worldhello@gmail.com
 ---
  builtin/blame.c | 19 ++-
  1 file changed, 14 insertions(+), 5 deletions(-)

 diff --git a/builtin/blame.c b/builtin/blame.c
 index 88cb799..0a0a858 100644
 --- a/builtin/blame.c
 +++ b/builtin/blame.c
 @@ -1556,22 +1556,31 @@ static void assign_blame(struct scoreboard *sb, int 
 opt)
  static const char *format_time(unsigned long time, const char *tz_str,
int show_raw_time)
  {
 -   static char time_buf[128];
 +   static struct strbuf time_buf = STRBUF_INIT;

 +   strbuf_reset(time_buf);
 if (show_raw_time) {
 -   snprintf(time_buf, sizeof(time_buf), %lu %s, time, tz_str);
 +   strbuf_addf(time_buf, %lu %s, time, tz_str);
 }
 else {
 const char *time_str;
 +   size_t time_width;
 int time_len;
 int tz;
 tz = atoi(tz_str);
 time_str = show_date(time, tz, blame_date_mode);
 time_len = strlen(time_str);
 -   memcpy(time_buf, time_str, time_len);
 -   memset(time_buf + time_len, ' ', blame_date_width - time_len);
 +   strbuf_add(time_buf, time_str, time_len);
 +   /*
 +* Add space paddings to time_buf to display a fixed width
 +* string, and use time_width for display width calibration.
 +*/
 +   for (time_width = utf8_strwidth(time_str);
 +time_width  blame_date_width;
 +time_width++)
 +   strbuf_addch(time_buf, ' ');
 }
 -   return time_buf;
 +   return time_buf.buf;
  }

  #define OUTPUT_ANNOTATE_COMPAT 001
 --
 2.0.0.rc0.3.g444188f.dirty
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] git-remote-hg : Enable use of, $GIT_DIR/hg/origin/clone/.hg/hgrc

2014-04-20 Thread Delcypher
 Same as me. And which version of git-remote-hg are you using?

I'm using the version that ships with git 1.9.2

I've taken a look and it seems I made a mistake, sorry. It seems that

[ui]
quiet = True

is being respected when placed in ``.git/hg/origin/clone/.hg/hgrc``

with the un patched version of git-remote-hg.

But it is still the case that authentication details are being ignored
when present in  ``.git/hg/origin/clone/.hg/hgrc``

i.e. something like the following is ignored.

[auth]
cc.prefix = hg.codeplex.com
cc.username = USERNAME
# Eurgh fixme this shouldn't live here.
cc.password = PWD
cc.schemes = https

and pushing fails. An easy way of duplicating this is forking a
project on codeplex (e.g. [1]), cloning that respository, making a
trivial commit and then trying to push that commit to your fork.

When I try this pushing fails because the authentication details are
being ignored in  ``.git/hg/origin/clone/.hg/hgrc``. Applying my patch
(or your improved version using repo.ui instead of
repo._unfilteredrepo.ui) fixes this for me.

[1] https://boogie.codeplex.com/SourceControl/latest
--
To unsubscribe from this list: send the line 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] git-remote-hg : Enable use of, $GIT_DIR/hg/origin/clone/.hg/hgrc

2014-04-20 Thread Felipe Contreras
Delcypher wrote:
  Same as me. And which version of git-remote-hg are you using?
 
 I'm using the version that ships with git 1.9.2
 
 I've taken a look and it seems I made a mistake, sorry. It seems that
 
 [ui]
 quiet = True
 
 is being respected when placed in ``.git/hg/origin/clone/.hg/hgrc``
 
 with the un patched version of git-remote-hg.
 
 But it is still the case that authentication details are being ignored
 when present in  ``.git/hg/origin/clone/.hg/hgrc``
 
 i.e. something like the following is ignored.
 
 [auth]
 cc.prefix = hg.codeplex.com
 cc.username = USERNAME
 # Eurgh fixme this shouldn't live here.
 cc.password = PWD
 cc.schemes = https

I see now, I've taken the patch with repo.ui and applied on my repo:

https://github.com/felipec/git/commit/ee17fe1cf80d5196be382ebbbcb1a24c05e61658

If Junio wants to take that he can add my s-o-b.

Cheers.

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


security vulnerability disclosure procedure?

2014-04-20 Thread Richard Hansen
Hi all,

I have discovered a minor security vulnerability.  I could send the
patch to the mailing list, but I wanted someone else to take a look
first just to make sure it's minor enough that folks will think it's OK
to publicly announce.

Who should I send the patch to?

Thanks,
Richard
--
To unsubscribe from this list: send the line 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 try3] branch: reorganize verbose options

2014-04-20 Thread Felipe Contreras
`git branch -v` before:

  fc/branch/nice-verbose 4761939 [master] branch: reorganize verbose options

`git branch -v` after:

  fc/branch/nice-verbose 4761939 [ahead 1] branch: reorganize verbose options

Showing the upstream tracking branch is more important than how many commits
are ahead/behind, after all you need to know ahead/behind compared to _what_.
So now `git branch -v` shows the upstream, but not the tracking info, and
`git branch -vv` shows all information (unchanged).

An additional benefit is that `git branch -v` is now much faster:

Before:

 git branch -v  0.01s user 0.01s system 90% cpu 0.014 total

After:

 git branch -v  1.67s user 0.03s system 99% cpu 1.698 total

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

diff --git a/builtin/branch.c b/builtin/branch.c
index b4d7716..8013540 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -417,29 +417,35 @@ static int ref_cmp(const void *r1, const void *r2)
 }
 
 static void fill_tracking_info(struct strbuf *stat, const char *branch_name,
-   int show_upstream_ref)
+   int show_tracking)
 {
int ours, theirs;
char *ref = NULL;
struct branch *branch = branch_get(branch_name);
struct strbuf fancy = STRBUF_INIT;
int upstream_is_gone = 0;
-   int added_decoration = 1;
 
-   switch (stat_tracking_info(branch, ours, theirs)) {
-   case 0:
-   /* no base */
+   if (!branch)
return;
-   case -1:
-   /* with gone base */
-   upstream_is_gone = 1;
-   break;
-   default:
-   /* with base */
-   break;
+
+   if (show_tracking) {
+   switch (stat_tracking_info(branch, ours, theirs)) {
+   case 0:
+   /* no base */
+   return;
+   case -1:
+   /* with gone base */
+   upstream_is_gone = 1;
+   break;
+   default:
+   /* with base */
+   break;
+   }
+   } else {
+   ours = theirs = 0;
}
 
-   if (show_upstream_ref) {
+   if (branch-merge  branch-merge[0]  branch-merge[0]-dst) {
ref = shorten_unambiguous_ref(branch-merge[0]-dst, 0);
if (want_color(branch_use_color))
strbuf_addf(fancy, %s%s%s,
@@ -448,39 +454,23 @@ static void fill_tracking_info(struct strbuf *stat, const 
char *branch_name,
else
strbuf_addstr(fancy, ref);
}
+   if (!fancy.len)
+   return;
 
-   if (upstream_is_gone) {
-   if (show_upstream_ref)
-   strbuf_addf(stat, _([%s: gone]), fancy.buf);
-   else
-   added_decoration = 0;
-   } else if (!ours  !theirs) {
-   if (show_upstream_ref)
-   strbuf_addf(stat, _([%s]), fancy.buf);
-   else
-   added_decoration = 0;
-   } else if (!ours) {
-   if (show_upstream_ref)
-   strbuf_addf(stat, _([%s: behind %d]), fancy.buf, 
theirs);
-   else
-   strbuf_addf(stat, _([behind %d]), theirs);
+   if (upstream_is_gone)
+   strbuf_addf(stat, _([%s: gone]), fancy.buf);
+   else if (!ours  !theirs)
+   strbuf_addf(stat, _([%s]), fancy.buf);
+   else if (!ours)
+   strbuf_addf(stat, _([%s: behind %d]), fancy.buf, theirs);
+   else if (!theirs)
+   strbuf_addf(stat, _([%s: ahead %d]), fancy.buf, ours);
+   else
+   strbuf_addf(stat, _([%s: ahead %d, behind %d]),
+   fancy.buf, ours, theirs);
 
-   } else if (!theirs) {
-   if (show_upstream_ref)
-   strbuf_addf(stat, _([%s: ahead %d]), fancy.buf, ours);
-   else
-   strbuf_addf(stat, _([ahead %d]), ours);
-   } else {
-   if (show_upstream_ref)
-   strbuf_addf(stat, _([%s: ahead %d, behind %d]),
-   fancy.buf, ours, theirs);
-   else
-   strbuf_addf(stat, _([ahead %d, behind %d]),
-   ours, theirs);
-   }
strbuf_release(fancy);
-   if (added_decoration)
-   strbuf_addch(stat, ' ');
+   strbuf_addch(stat, ' ');
free(ref);
 }
 
diff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh
index 7ac8fd0..af26db5 100755
--- a/t/t6040-tracking-info.sh
+++ b/t/t6040-tracking-info.sh
@@ -41,12 +41,12 @@ test_expect_success setup '
 
 script='s/^..\(b.\) *[0-9a-f]* 

Re: [PATCH 0/5] fc/transport-helper-sync-error-fix rebased

2014-04-20 Thread Felipe Contreras
Junio C Hamano wrote:
 Felipe Contreras felipe.contre...@gmail.com writes:
 
  Junio C Hamano wrote:
  As I have said in the recent What's cooking reports, the original
  posted here were based on older codebase and needed to be rebased,
  but it had some conflicts and I wanted to see the result double
  checked by the original author before we can merge it to 'next',
  cooked there and hopefully merged to 'master' before tagging -rc1.
  
  So here is the series that has been queued in 'pu' for the past
  several days.
  
  Felipe, can you double check it?
 
  These patches don't help much,...
 
 What do you mean by that, exactly?  As long as your don't help
 much is would not hurt and will help some even for a small subset
 of audience, that would be OK, but I am puzzled.

I mean if purpose of these was for me to review the changes you did, it doesn't
help as much as an interdiff does.

 My reading of your responses to bug reports and the cover letter of
 the series has been that these were real fixes to a real problem
 without downsides, and that you consider that they are good changes
 to have in the upcoming release.
 
 I am hoping that you did not mean that we shouldn't merge it to the
 'next' and 'master' branches, but if that is what you meant, can we
 hear what the downsides of the series are?
 Are they more churn than they are worth without solving the real
 issue?  Do they regress for some repositories/workflows while
 improving for others?  I didn't get such an impression.

That's not what I meant. The patches are good.

  ..., I did and interdiff with my own fixes and this is the result:
  ...  I don't like it, but it's OK.
 
 Correct.  Following the coding style of the project is not the
 matter for your liking or not liking.  It is part of being on the
 same codebase with other participant of this project.

There's nothing in Documentation/CodingGuidelines that says multiple piped
commands should be one on each line even if togther the line doesn't exceed 80
characters, nor does it says that file names should be between quotes, even if
the file name can't possibly have spaces.

These are just your arbitrary rules, not the guidelines of the project.

And BTW, the fact that something is a rule doesn't mean it's good; rules change.

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


Re: [PATCH] git-remote-hg : Enable use of, $GIT_DIR/hg/origin/clone/.hg/hgrc

2014-04-20 Thread Delcypher
 I see now, I've taken the patch with repo.ui and applied on my repo:

 https://github.com/felipec/git/commit/ee17fe1cf80d5196be382ebbbcb1a24c05e61658

Thanks.

It might be helpful to catch the exception raised if https
authentication details are missing so that a more user friendly error
message can be presented. I considered doing this but I wasn't
entirely sure how to correctly do any necessary clean up.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 2/2] blame: use different blame_date_width for different locale

2014-04-20 Thread Junio C Hamano
Jiang Xin worldhello@gmail.com writes:

 When show date in relative date format for `git blame`, the max display
 width of datetime is set as the length of the string Thu Oct 19
 16:00:04 2006 -0700 (30 characters long).  But actually the max width
 for C locale is only 22 (the length of string x years, xx months ago).
 And for other locale, it maybe smaller.  E.g. For Chinese locale, only
 needs 16-character width.

 Set blame_date_width as the display width of _(4 years, 11 months
 ago), so that translators can make the choice.

 Signed-off-by: Jiang Xin worldhello@gmail.com
 ---
  builtin/blame.c | 10 +-
  1 file changed, 9 insertions(+), 1 deletion(-)

 diff --git a/builtin/blame.c b/builtin/blame.c
 index 0a0a858..9350ea3 100644
 --- a/builtin/blame.c
 +++ b/builtin/blame.c
 @@ -2340,7 +2340,15 @@ parse_done:
   blame_date_width = sizeof(2006-10-19);
   break;
   case DATE_RELATIVE:
 - /* normal is used as the fallback for relative */
 + /* TRANSLATORS: what we care about is not the content itself,
 +but the display width of this string.  We use the width of
 +the string as the max width of the datetime in relative
 +format.  For English and many other languages, 4 years,
 +11 months ago is the longest one among 89 seconds ago,
 +89 minites ago, 35 hours ago, 13 days ago, 10 weeks
 +ago, in the future and many others. */
 + blame_date_width = utf8_strwidth(_(4 years, 11 months ago)) + 
 1; /* add the null */
 + break;


This is not wrong per-se, but I am not sure if translators would
understand that years and months ago may not be the longuest
variant for their language and they are asked to use 89 seconds
ago if the translation of that is longer than the translation for
4 years, 11 months ago in their language, with the given
explanation.

How about dropping the second sentence We use... and end the
comment with something like:

ago, in the future and many others.  It is possible that
the translation of 89 seconds ago may be the longest
possible translation in your language (then by definition,
it would be longer than the translation of this string in
your language), and in such a case, please write the
translation of 89 seconds ago here.

Actually, even though many others is correct, the possibilities
are within a bounded set of template i18n formats, no?  I wonder if
it would be nicer to the translators if we did not use a single
representative string here, but add a helper function to date.c
that goes something like:

int date_relative_maxwidth(void)
{
struct strbuf buf = STRBUF_INIT;
static int length;

if (length)
return length;

strbuf_addf(buf, _(in the future));
length = (length  buf.len) ? buf.len : length;
strbuf_addf(buf, Q_(%lu second ago, %lu seconds ago, 89), 89);
length = (length  buf.len) ? buf.len : length;
...
strbuf_addf(buf, Q_(%lu year ago, %lu years ago, ), );
length = (length  buf.len) ? buf.len : length;

return length;
}

immediately after the definition of show_date_relative() and used it
in this codepath?

Of course, given a date that is far enough into the future, the
actuall length is unbounded, so this approach will not come up with
the absolute minimum width to align all lines (you would need to do
a two pass, measuring how wide all timestamps that would appear in
the output before producing the first line of the output---but I do
not think it is worth it, and as long as we do not overflow the
buffer, showing occasional misalignment for a line that came from
year 27342 is much better than a worse latency-to-first-output).

   case DATE_LOCAL:
   case DATE_NORMAL:
   blame_date_width = sizeof(Thu Oct 19 16:00:04 2006 -0700);
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] remote-helpers: graduate

2014-04-20 Thread Felipe Contreras
There doesn't seem to be any reason to keep these remote-helpers in the contrib
area.

Felipe Contreras (2):
  remote-helpers: move out of contrib
  remote-helpers: move tests out of contrib

 .gitignore |  2 ++
 Makefile   |  2 ++
 contrib/remote-helpers/Makefile| 14 --
 contrib/remote-helpers/git-remote-bzr = git-remote-bzr.py |  0
 contrib/remote-helpers/git-remote-hg = git-remote-hg.py   |  0
 t/Makefile |  8 +++-
 .../remote-helpers/test-bzr.sh = t/remote-helpers/bzr.t   |  4 ++--
 .../test-hg-bidi.sh = t/remote-helpers/hg-bidi.t  |  4 ++--
 .../test-hg-hg-git.sh = t/remote-helpers/hg-hg-git.t  |  6 +++---
 contrib/remote-helpers/test-hg.sh = t/remote-helpers/hg.t |  4 ++--
 10 files changed, 20 insertions(+), 24 deletions(-)
 delete mode 100644 contrib/remote-helpers/Makefile
 rename contrib/remote-helpers/git-remote-bzr = git-remote-bzr.py (100%)
 rename contrib/remote-helpers/git-remote-hg = git-remote-hg.py (100%)
 rename contrib/remote-helpers/test-bzr.sh = t/remote-helpers/bzr.t (98%)
 rename contrib/remote-helpers/test-hg-bidi.sh = t/remote-helpers/hg-bidi.t 
(97%)
 rename contrib/remote-helpers/test-hg-hg-git.sh = 
t/remote-helpers/hg-hg-git.t (98%)
 rename contrib/remote-helpers/test-hg.sh = t/remote-helpers/hg.t (99%)

-- 
1.9.1+fc3.9.gc73078e

--
To unsubscribe from this list: send the line 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] remote-helpers: move out of contrib

2014-04-20 Thread Felipe Contreras
The remote-helpers in contrib/remote-helpers have proved to work, be
reliable, and stable. It's time to move them out of contrib, and be
distributed by default.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 .gitignore | 2 ++
 Makefile   | 2 ++
 contrib/remote-helpers/test-bzr.sh | 2 +-
 contrib/remote-helpers/test-hg-bidi.sh | 2 +-
 contrib/remote-helpers/test-hg-hg-git.sh   | 4 ++--
 contrib/remote-helpers/test-hg.sh  | 2 +-
 contrib/remote-helpers/git-remote-bzr = git-remote-bzr.py | 0
 contrib/remote-helpers/git-remote-hg = git-remote-hg.py   | 0
 8 files changed, 9 insertions(+), 5 deletions(-)
 rename contrib/remote-helpers/git-remote-bzr = git-remote-bzr.py (100%)
 rename contrib/remote-helpers/git-remote-hg = git-remote-hg.py (100%)

diff --git a/.gitignore b/.gitignore
index dc600f9..db5f15e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -119,11 +119,13 @@
 /git-reflog
 /git-relink
 /git-remote
+/git-remote-bzr
 /git-remote-http
 /git-remote-https
 /git-remote-ftp
 /git-remote-ftps
 /git-remote-fd
+/git-remote-hg
 /git-remote-ext
 /git-remote-testgit
 /git-remote-testpy
diff --git a/Makefile b/Makefile
index 2128ce3..fda4567 100644
--- a/Makefile
+++ b/Makefile
@@ -483,6 +483,8 @@ SCRIPT_PERL += git-send-email.perl
 SCRIPT_PERL += git-svn.perl
 
 SCRIPT_PYTHON += git-p4.py
+SCRIPT_PYTHON += git-remote-hg.py
+SCRIPT_PYTHON += git-remote-bzr.py
 
 NO_INSTALL += git-remote-testgit
 
diff --git a/contrib/remote-helpers/test-bzr.sh 
b/contrib/remote-helpers/test-bzr.sh
index a4656ce..330b147 100755
--- a/contrib/remote-helpers/test-bzr.sh
+++ b/contrib/remote-helpers/test-bzr.sh
@@ -14,7 +14,7 @@ then
test_done
 fi
 
-if ! python -c 'import bzrlib'
+if ! $PYTHON_PATH -c 'import bzrlib'
 then
skip_all='skipping remote-bzr tests; bzr not available'
test_done
diff --git a/contrib/remote-helpers/test-hg-bidi.sh 
b/contrib/remote-helpers/test-hg-bidi.sh
index d86e147..e963745 100755
--- a/contrib/remote-helpers/test-hg-bidi.sh
+++ b/contrib/remote-helpers/test-hg-bidi.sh
@@ -17,7 +17,7 @@ then
test_done
 fi
 
-if ! python -c 'import mercurial'
+if ! $PYTHON_PATH -c 'import mercurial'
 then
skip_all='skipping remote-hg tests; mercurial not available'
test_done
diff --git a/contrib/remote-helpers/test-hg-hg-git.sh 
b/contrib/remote-helpers/test-hg-hg-git.sh
index b23909a..c6b4541 100755
--- a/contrib/remote-helpers/test-hg-hg-git.sh
+++ b/contrib/remote-helpers/test-hg-hg-git.sh
@@ -17,13 +17,13 @@ then
test_done
 fi
 
-if ! python -c 'import mercurial'
+if ! $PYTHON_PATH -c 'import mercurial'
 then
skip_all='skipping remote-hg tests; mercurial not available'
test_done
 fi
 
-if ! python -c 'import hggit'
+if ! $PYTHON_PATH -c 'import hggit'
 then
skip_all='skipping remote-hg tests; hg-git not available'
test_done
diff --git a/contrib/remote-helpers/test-hg.sh 
b/contrib/remote-helpers/test-hg.sh
index 7d90056..00b7dde 100755
--- a/contrib/remote-helpers/test-hg.sh
+++ b/contrib/remote-helpers/test-hg.sh
@@ -17,7 +17,7 @@ then
test_done
 fi
 
-if ! python -c 'import mercurial'
+if ! $PYTHON_PATH -c 'import mercurial'
 then
skip_all='skipping remote-hg tests; mercurial not available'
test_done
diff --git a/contrib/remote-helpers/git-remote-bzr b/git-remote-bzr.py
similarity index 100%
rename from contrib/remote-helpers/git-remote-bzr
rename to git-remote-bzr.py
diff --git a/contrib/remote-helpers/git-remote-hg b/git-remote-hg.py
similarity index 100%
rename from contrib/remote-helpers/git-remote-hg
rename to git-remote-hg.py
-- 
1.9.1+fc3.9.gc73078e

--
To unsubscribe from this list: send the line 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] remote-helpers: move tests out of contrib

2014-04-20 Thread Felipe Contreras
They should be tested by default.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 contrib/remote-helpers/Makefile| 14 --
 t/Makefile |  8 +++-
 .../remote-helpers/test-bzr.sh = t/remote-helpers/bzr.t   |  2 +-
 .../test-hg-bidi.sh = t/remote-helpers/hg-bidi.t  |  2 +-
 .../test-hg-hg-git.sh = t/remote-helpers/hg-hg-git.t  |  2 +-
 contrib/remote-helpers/test-hg.sh = t/remote-helpers/hg.t |  2 +-
 6 files changed, 11 insertions(+), 19 deletions(-)
 delete mode 100644 contrib/remote-helpers/Makefile
 rename contrib/remote-helpers/test-bzr.sh = t/remote-helpers/bzr.t (99%)
 rename contrib/remote-helpers/test-hg-bidi.sh = t/remote-helpers/hg-bidi.t 
(98%)
 rename contrib/remote-helpers/test-hg-hg-git.sh = 
t/remote-helpers/hg-hg-git.t (99%)
 rename contrib/remote-helpers/test-hg.sh = t/remote-helpers/hg.t (99%)

diff --git a/contrib/remote-helpers/Makefile b/contrib/remote-helpers/Makefile
deleted file mode 100644
index 239161d..000
--- a/contrib/remote-helpers/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-TESTS := $(wildcard test*.sh)
-
-export T := $(addprefix $(CURDIR)/,$(TESTS))
-export MAKE := $(MAKE) -e
-export PATH := $(CURDIR):$(PATH)
-export TEST_LINT := test-lint-executable test-lint-shell-syntax
-
-test:
-   $(MAKE) -C ../../t $@
-
-$(TESTS):
-   $(MAKE) -C ../../t $(CURDIR)/$@
-
-.PHONY: $(TESTS)
diff --git a/t/Makefile b/t/Makefile
index 8fd1a72..818f4ed 100644
--- a/t/Makefile
+++ b/t/Makefile
@@ -14,6 +14,7 @@ RM ?= rm -f
 PROVE ?= prove
 DEFAULT_TEST_TARGET ?= test
 TEST_LINT ?= test-lint-duplicates test-lint-executable
+export TEST_DIRECTORY = $(CURDIR)
 
 ifdef TEST_OUTPUT_DIRECTORY
 TEST_RESULTS_DIRECTORY = $(TEST_OUTPUT_DIRECTORY)/test-results
@@ -29,6 +30,9 @@ TEST_RESULTS_DIRECTORY_SQ = $(subst 
','\'',$(TEST_RESULTS_DIRECTORY))
 T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
 TSVN = $(sort $(wildcard t91[0-9][0-9]-*.sh))
 TGITWEB = $(sort $(wildcard t95[0-9][0-9]-*.sh))
+TREMOTE = $(wildcard remote-helpers/*.t)
+
+T += $(TREMOTE)
 
 all: $(DEFAULT_TEST_TARGET)
 
@@ -55,7 +59,7 @@ clean: clean-except-prove-cache
 test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax
 
 test-lint-duplicates:
-   @dups=`echo $(T) | tr ' ' '\n' | sed 's/-.*//' | sort | uniq -d`  \
+   @dups=`echo $(filter-out $(TREMOTE),$(T)) | tr ' ' '\n' | sed 's/-.*//' 
| sort | uniq -d`  \
test -z $$dups || { \
echo 2 duplicate test numbers: $$dups; exit 1; }
 
@@ -84,6 +88,8 @@ full-svn-test:
 gitweb-test:
$(MAKE) $(TGITWEB)
 
+remote-helpers-test: $(TREMOTE)
+
 valgrind:
$(MAKE) GIT_TEST_OPTS=$(GIT_TEST_OPTS) --valgrind
 
diff --git a/contrib/remote-helpers/test-bzr.sh b/t/remote-helpers/bzr.t
similarity index 99%
rename from contrib/remote-helpers/test-bzr.sh
rename to t/remote-helpers/bzr.t
index 330b147..066e326 100755
--- a/contrib/remote-helpers/test-bzr.sh
+++ b/t/remote-helpers/bzr.t
@@ -5,7 +5,7 @@
 
 test_description='Test remote-bzr'
 
-test -n $TEST_DIRECTORY || TEST_DIRECTORY=${0%/*}/../../t
+test -n $TEST_DIRECTORY || TEST_DIRECTORY=${0%/*}/..
 . $TEST_DIRECTORY/test-lib.sh
 
 if ! test_have_prereq PYTHON
diff --git a/contrib/remote-helpers/test-hg-bidi.sh b/t/remote-helpers/hg-bidi.t
similarity index 98%
rename from contrib/remote-helpers/test-hg-bidi.sh
rename to t/remote-helpers/hg-bidi.t
index e963745..f6c51b0 100755
--- a/contrib/remote-helpers/test-hg-bidi.sh
+++ b/t/remote-helpers/hg-bidi.t
@@ -8,7 +8,7 @@
 
 test_description='Test bidirectionality of remote-hg'
 
-test -n $TEST_DIRECTORY || TEST_DIRECTORY=${0%/*}/../../t
+test -n $TEST_DIRECTORY || TEST_DIRECTORY=${0%/*}/..
 . $TEST_DIRECTORY/test-lib.sh
 
 if ! test_have_prereq PYTHON
diff --git a/contrib/remote-helpers/test-hg-hg-git.sh 
b/t/remote-helpers/hg-hg-git.t
similarity index 99%
rename from contrib/remote-helpers/test-hg-hg-git.sh
rename to t/remote-helpers/hg-hg-git.t
index c6b4541..12e2d51 100755
--- a/contrib/remote-helpers/test-hg-hg-git.sh
+++ b/t/remote-helpers/hg-hg-git.t
@@ -8,7 +8,7 @@
 
 test_description='Test remote-hg output compared to hg-git'
 
-test -n $TEST_DIRECTORY || TEST_DIRECTORY=${0%/*}/../../t
+test -n $TEST_DIRECTORY || TEST_DIRECTORY=${0%/*}/..
 . $TEST_DIRECTORY/test-lib.sh
 
 if ! test_have_prereq PYTHON
diff --git a/contrib/remote-helpers/test-hg.sh b/t/remote-helpers/hg.t
similarity index 99%
rename from contrib/remote-helpers/test-hg.sh
rename to t/remote-helpers/hg.t
index 00b7dde..b4f26e7 100755
--- a/contrib/remote-helpers/test-hg.sh
+++ b/t/remote-helpers/hg.t
@@ -8,7 +8,7 @@
 
 test_description='Test remote-hg'
 
-test -n $TEST_DIRECTORY || TEST_DIRECTORY=${0%/*}/../../t
+test -n $TEST_DIRECTORY || TEST_DIRECTORY=${0%/*}/..
 . $TEST_DIRECTORY/test-lib.sh
 
 if ! test_have_prereq PYTHON
-- 
1.9.1+fc3.9.gc73078e

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a 

Re: [PATCH 0/5] fc/transport-helper-sync-error-fix rebased

2014-04-20 Thread Junio C Hamano
Felipe Contreras felipe.contre...@gmail.com writes:

 Junio C Hamano wrote:
 Felipe Contreras felipe.contre...@gmail.com writes:
 
  Junio C Hamano wrote:
  As I have said in the recent What's cooking reports, the original
  posted here were based on older codebase and needed to be rebased,
  but it had some conflicts and I wanted to see the result double
  checked by the original author before we can merge it to 'next',
  cooked there and hopefully merged to 'master' before tagging -rc1.
  
  So here is the series that has been queued in 'pu' for the past
  several days.
  
  Felipe, can you double check it?
 
  These patches don't help much,...
 
 What do you mean by that, exactly?  As long as your don't help
 much is would not hurt and will help some even for a small subset
 of audience, that would be OK, but I am puzzled.

 I mean if purpose of these was for me to review the changes you did, it 
 doesn't
 help as much as an interdiff does.

Ah, I misunderstood.  The thing was, that the original was based on
older codebase and I couldn't apply them to my tree cleanly.  It
would be unfair for you to expect _me_ to give you an interdiff in
such a situation, especially when I am asking you to double check
the conflict resolution based on that original.

OK, so I'll advance the topic to the 'next' and hopefully we can
merge it to 'master' before rc1.

 There's nothing in Documentation/CodingGuidelines that says multiple piped
 commands should be one on each line even if togther the line doesn't exceed 80
 characters, nor does it says that file names should be between quotes, even if
 the file name can't possibly have spaces.

Heh, we don't spell out every possible rules. That is where do as
surrounding code comes in.

As to $1 vs $1 without quotes, I had to check the calling sites of
clean_mark and cmp_marks, primarily because these functions do not
say what their $1 is, to see if an unquoted form is safe.  The
next person who reads the script has to do the same and quoting is
an obvious way to avoid it.

If the functions said $1 is a branch name, it would have been
clear that unquoted $1 would be OK, but still, what these functions
has to take (especially the clean one that takes pathnames) can
change in the future, and a quoted form is an obvious way to
futureproof and relieve readers and programmers from having to worry
about the quoting issues.

So I think it is better to quote these in this particular case.

The pipe is purely subjective readability. I can go either way, but
since I was the one who was applying the patch that needed other
changes anyway... ;-)

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


Re: [PATCH 0/5] fc/transport-helper-sync-error-fix rebased

2014-04-20 Thread Felipe Contreras
Junio C Hamano wrote:
 So I think it is better to quote these in this particular case.
 
 The pipe is purely subjective readability. I can go either way, but
 since I was the one who was applying the patch that needed other
 changes anyway... ;-)

You started by saying these were not the matter for your liking or not
liking, and now you are explaining why you like one better than the other.

I don't think it's particularly helpful to criticize one person's preferences
because they don't match yours.

You like one, I like another. That's it.

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


Re: [msysGit] Re: Re: [ANNOUNCE] WinGit - native x86/x64 Git for Windows

2014-04-20 Thread Johannes Schindelin
Hi Heiko,

On Sat, 19 Apr 2014, Heiko Voigt wrote:

 Regarding mingwGitDevEnv[2]: That is a project started by Sebastian who
 also contributes to msysgit (and Git for Windows).

In fact, Sebastian is not only a contributor. He is co-maintainer of Git
for Windows.

 It eventually can (and probably should) be a successor of the current
 situation [...]

Sebastian hinted at it in many a discussion on the msysgit mailing list
(where those people who are serious about Git for Windows development hang
out, hint, hint, hint) that mingwGitDevEnv was born out of the needs
identified while maintaining Git for Windows.

Our tentative plan is to switch with Git 2.0 (unless the timing turns out
to be unfortunate). We have to put some more effort into mingwGitDevEnv
first, though: due to the differences between the old MSys committed into
msysgit.git repository on the one hand, and the MSys environment
initialized and updated by mingwGitDevEnv on the other hand, some of the
tests do not pass yet. (I also would like to look into getting the
performance improvement Hannes Sixt achieved by his patch [*1*] into
mingwGitDevEnv's Git installation, too.)

Despite the common lack of time and of developers willing to spend time to
contribute to the Git for Windows effort, I think we are well on track,
and it will be pretty exciting when we switch to mingwGitDevEnv-based
development of Git for Windows!

Ciao,
Dscho
--
To unsubscribe from this list: send the line 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: [msysGit] Re: Re: [ANNOUNCE] WinGit - native x86/x64 Git for Windows

2014-04-20 Thread Johannes Schindelin
On Mon, 21 Apr 2014, Johannes Schindelin wrote:

 (I also would like to look into getting the performance improvement
 Hannes Sixt achieved by his patch [*1*] into mingwGitDevEnv's Git
 installation, too.)

Whoops. Footnote *1*: https://github.com/msysgit/msysgit/commit/a0f5d4f
--
To unsubscribe from this list: send the line 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: the .git folder

2014-04-20 Thread Junio C Hamano
Duy Nguyen pclo...@gmail.com writes:

 On Sun, Apr 20, 2014 at 4:13 PM, Miller, Hugh hughmil...@chevron.com wrote:
 Dear Community,

 Is there any way to use .git (e.g., a different set of client commands) 
 that allows the .git folder to be placed in a location away from the actual 
 files being versioned ? For example, can one set environment variables that 
 let the software know where the .git folder is ?

 Try

 git --git-dir=new .git location --work-tree=top work tree location
 some command

 The reason of two arguments instead of one is because .git is also
 used to mark top work tree location, which is now lost after you move
 .git elsewhere. You could also set environment variables GIT_DIR and
 GIT_WORK_TREE, which have the same effect. man git for details.

Depending on the true reason why such a split layout is desired, the
answer might be the textual .git (aka gitfile: there) that is used
by the submodule folks via clone --separate-git-dir.


--
To unsubscribe from this list: send the line 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] t5801 (remote-helpers): cleanup environment sets

2014-04-20 Thread Junio C Hamano
Felipe Contreras felipe.contre...@gmail.com writes:

 Commit 512477b (tests: use env to run commands with temporary env-var
 settings) missed some variables in the remote-helpers test. Also
 standardize these.

 Signed-off-by: Felipe Contreras felipe.contre...@gmail.com

Good.  I was wondering about these myself when juggling some series
that touched this file the other day.

Will queue.  Thanks.


 ---
  t/t5801-remote-helpers.sh | 15 +++
  1 file changed, 7 insertions(+), 8 deletions(-)

 diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
 index 25fd2e7..42d1c66 100755
 --- a/t/t5801-remote-helpers.sh
 +++ b/t/t5801-remote-helpers.sh
 @@ -212,19 +212,17 @@ test_expect_success 'push update refs failure' '
   echo update fail file 
   git commit -a -m update fail 
   git rev-parse --verify testgit/origin/heads/update expect 
 - GIT_REMOTE_TESTGIT_PUSH_ERROR=non-fast forward 
 - export GIT_REMOTE_TESTGIT_PUSH_ERROR 
 - test_expect_code 1 git push origin update 
 + test_expect_code 1 env GIT_REMOTE_TESTGIT_FAILURE=non-fast forward \
 + git push origin update 
   git rev-parse --verify testgit/origin/heads/update actual 
   test_cmp expect actual
   )
  '
  
  test_expect_success 'proper failure checks for fetching' '
 - (GIT_REMOTE_TESTGIT_FAILURE=1 
 - export GIT_REMOTE_TESTGIT_FAILURE 
 - cd local 
 - test_must_fail git fetch 2 error 
 + (cd local 
 + test_must_fail env GIT_REMOTE_TESTGIT_FAILURE=1 \
 + git fetch 2 error 
   cat error 
   grep -q Error while running fast-import error
   )
 @@ -232,7 +230,8 @@ test_expect_success 'proper failure checks for fetching' '
  
  test_expect_success 'proper failure checks for pushing' '
   (cd local 
 - test_must_fail env GIT_REMOTE_TESTGIT_FAILURE=1 git push --all
 + test_must_fail env GIT_REMOTE_TESTGIT_FAILURE=1 \
 + git push --all
   )
  '
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


What is missing from Git v2.0

2014-04-20 Thread Felipe Contreras
Hi,

I had already given up on merging important features to Git upstream,
and then one of the features I've had in git-fc (my fork) for quite
some time suddenly got attention (the @{publish} branch), but
everybody forgot I already did the work. So maybe there's other
features in a similar situation.

= The publish tracking branch =

Git's triangular workflow support is definitely lacking, and although
there are many ideas and workarounds, the simplest and most
user-friendly way to fix the issues is by introducing the concept of a
publish tracking branch, similar to the upstream tracking branch.

Fortunately this might actually get into v2.0.

[1][2]

= Reject non-fast-forward pulls by default =

Many new-comers end up making merges by mistake when they pull because
they don't understand what is a non-fast-forward and what they should
actually be doing. Most people, even Linus Torvalds, agreed that by
default `git pull` should fail and guide the user, instead of silently
making a merge which might not be what the user wants (even though he
doesn't know it), and messing up the project's history, which affects
other people.

The patches were sent, the issues were addressed, people agreed, and
yet nothing happened.

[3][4]

= Use stage instead of index =

Everybody, and by everybody I literally mean everyone except Junio,
have agreed that index is a horrible name of the high-level concept
(not the actual index file) of the pace where the user drafts a
commit. Different actions were proposed to move towards a saner name,
and the simplest sensible one seems to be to start renaming the
confusing --cached and --index options to --stage and --no-work, and
also to add a new `git stage` command.

Nothing happened.

[5][6][7][8]

= Default aliases =

Every single version control tool out there has default aliases (e.g.
co = checkout) except Git.

Every argument against default aliases was basically refuted, yet my
patches went nowhere. And the users still expect these aliases.

[9]

[1] http://thread.gmane.org/gmane.comp.version-control.git/235981
[2] http://thread.gmane.org/gmane.comp.version-control.git/240030
[3] http://thread.gmane.org/gmane.comp.version-control.git/240030
[4] http://thread.gmane.org/gmane.comp.version-control.git/235981
[5] http://thread.gmane.org/gmane.comp.version-control.git/233295
[6] http://thread.gmane.org/gmane.comp.version-control.git/197111
[7] http://thread.gmane.org/gmane.comp.version-control.git/166675
[8] http://thread.gmane.org/gmane.comp.version-control.git/115666
[9] http://thread.gmane.org/gmane.comp.version-control.git/235145

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


Re: What is missing from Git v2.0

2014-04-20 Thread Felipe Contreras
On Sun, Apr 20, 2014 at 5:41 PM, Felipe Contreras
felipe.contre...@gmail.com wrote:

 [3] http://thread.gmane.org/gmane.comp.version-control.git/240030
 [4] http://thread.gmane.org/gmane.comp.version-control.git/235981

Actually:

[3] http://thread.gmane.org/gmane.comp.version-control.git/233554
[4] http://thread.gmane.org/gmane.comp.version-control.git/234295

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


[PATCH 1/2] merge: enable defaulttoupstream by default

2014-04-20 Thread Felipe Contreras
There's no point in this:

% git merge
fatal: No commit specified and merge.defaultToUpstream not set.

We know the most likely scenario is that the user wants to merge the
upstream, and if not, he can set merge.defaultToUpstream to false.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 Documentation/git-merge.txt | 5 ++---
 builtin/merge.c | 2 +-
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt
index a3c1fa3..cf2c374 100644
--- a/Documentation/git-merge.txt
+++ b/Documentation/git-merge.txt
@@ -101,9 +101,8 @@ commit or stash your changes before running 'git merge'.
Specifying more than one commit will create a merge with
more than two parents (affectionately called an Octopus merge).
 +
-If no commit is given from the command line, and if `merge.defaultToUpstream`
-configuration variable is set, merge the remote-tracking branches
-that the current branch is configured to use as its upstream.
+If no commit is given from the command line, merge the remote-tracking
+branches that the current branch is configured to use as its upstream.
 See also the configuration section of this manual page.
 
 
diff --git a/builtin/merge.c b/builtin/merge.c
index 66d8843..1fc9319 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -63,7 +63,7 @@ static int verbosity;
 static int allow_rerere_auto;
 static int abort_current_merge;
 static int show_progress = -1;
-static int default_to_upstream;
+static int default_to_upstream = 1;
 static const char *sign_commit;
 
 static struct strategy all_strategy[] = {
-- 
1.9.2+fc1.1.g5c924db

--
To unsubscribe from this list: send the line 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] mergetool: run prompt only if guessed tool

2014-04-20 Thread Felipe Contreras
It's annoying to see the prompt:

  Hit return to start merge resolution tool (foo):

Every time the user does 'git mergetool' even if the user already
configured 'foo' as the wanted tool.

Display this prompt only when the user hasn't explicitly configured a
tool.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 git-mergetool.sh | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/git-mergetool.sh b/git-mergetool.sh
index 332528f..d08dc92 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -277,7 +277,7 @@ merge_file () {
echo Normal merge conflict for '$MERGED':
describe_file $local_mode local $LOCAL
describe_file $remote_mode remote $REMOTE
-   if $prompt = true
+   if test $guessed_merge_tool = true || test $prompt = true
then
printf Hit return to start merge resolution tool (%s):  
$merge_tool
read ans || return 1
@@ -315,7 +315,8 @@ merge_file () {
return 0
 }
 
-prompt=$(git config --bool mergetool.prompt || echo true)
+prompt=$(git config --bool mergetool.prompt)
+guessed_merge_tool=false
 
 while test $# != 0
 do
@@ -373,7 +374,14 @@ prompt_after_failed_merge () {
 
 if test -z $merge_tool
 then
-   merge_tool=$(get_merge_tool $merge_tool) || exit
+   # Check if a merge tool has been configured
+   merge_tool=$(get_configured_merge_tool)
+   # Try to guess an appropriate merge tool if no tool has been set.
+   if test -z $merge_tool
+   then
+   merge_tool=$(guess_merge_tool) || exit
+   guessed_merge_tool=true
+   fi
 fi
 merge_keep_backup=$(git config --bool mergetool.keepBackup || echo true)
 merge_keep_temporaries=$(git config --bool mergetool.keepTemporaries || echo 
false)
-- 
1.9.2+fc1.1.g5c924db

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


[PATCH 0/2] Simple default fixes for v2.0

2014-04-20 Thread Felipe Contreras
I don't see why people need to set these to have sensible behavior:

  merge.defaulttoupstream = true
  mergetool.prompt = false

Let's change them to sane defaults so they are not needed.

Felipe Contreras (2):
  merge: enable defaulttoupstream by default
  mergetool: run prompt only if guessed tool

 Documentation/git-merge.txt |  5 ++---
 builtin/merge.c |  2 +-
 git-mergetool.sh| 14 +++---
 3 files changed, 14 insertions(+), 7 deletions(-)

-- 
1.9.2+fc1.1.g5c924db

--
To unsubscribe from this list: send the line 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] mergetools: add vimdiff3 mode

2014-04-20 Thread Felipe Contreras
It's similar to the default, except that the other windows are hidden.
This ensures that removed/added colors are still visible on the main
merge window, but the other windows not visible.

Specially useful with merge.conflictstyle=diff3.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---

How a conflict looks:
http://felipec.org/vimdiff3-conflict.png

How it looks resolved:
http://felipec.org/vimdiff3-resolved.png

 mergetools/gvimdiff3 |  1 +
 mergetools/vimdiff   | 14 --
 mergetools/vimdiff3  |  1 +
 3 files changed, 14 insertions(+), 2 deletions(-)
 create mode 100644 mergetools/gvimdiff3
 create mode 100644 mergetools/vimdiff3

diff --git a/mergetools/gvimdiff3 b/mergetools/gvimdiff3
new file mode 100644
index 000..04a5bb0
--- /dev/null
+++ b/mergetools/gvimdiff3
@@ -0,0 +1 @@
+. $MERGE_TOOLS_DIR/vimdiff
diff --git a/mergetools/vimdiff b/mergetools/vimdiff
index 39d0327..1ddfbfc 100644
--- a/mergetools/vimdiff
+++ b/mergetools/vimdiff
@@ -20,16 +20,26 @@ merge_cmd () {
$merge_tool_path -f -d -c 'wincmd l' \
$LOCAL $MERGED $REMOTE
;;
+   gvimdiff3|vimdiff3)
+   if $base_present
+   then
+   $merge_tool_path -f -d -c 'hid | hid | hid' \
+   $LOCAL $REMOTE $BASE $MERGED
+   else
+   $merge_tool_path -f -d -c 'hid | hid' \
+   $LOCAL $REMOTE $MERGED
+   fi
+   ;;
esac
check_unchanged
 }
 
 translate_merge_tool_path() {
case $1 in
-   gvimdiff|gvimdiff2)
+   gvimdiff|gvimdiff2|gvimdiff3)
echo gvim
;;
-   vimdiff|vimdiff2)
+   vimdiff|vimdiff2|vimdiff3)
echo vim
;;
esac
diff --git a/mergetools/vimdiff3 b/mergetools/vimdiff3
new file mode 100644
index 000..04a5bb0
--- /dev/null
+++ b/mergetools/vimdiff3
@@ -0,0 +1 @@
+. $MERGE_TOOLS_DIR/vimdiff
-- 
1.9.2+fc1.1.g5c924db

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


error: git-remote-https died of signal 13

2014-04-20 Thread Greg M
Hi,

Using git version 1.9.2 I am getting this error:

[normal@laptop tmp]$ git clone https://github.com/mozilla/rust.git
Cloning into 'rust'...
remote: Reusing existing pack: 296648, done.
remote: Counting objects: 80, done.
remote: Compressing objects: 100% (77/77), done.
remote: Total 296728 (delta 22), reused 9 (delta 3)
Receiving objects: 100% (296728/296728), 110.68 MiB | 190.00 KiB/s, done.
Resolving deltas: 100% (238828/238828), done.
Checking connectivity... done.
error: git-remote-https died of signal 13

The repository appears to be cloned fine, I can clone other repositories
without error.

I appear to have the exact same symptoms as Stefan in November 2013 as
archived here:
http://thread.gmane.org/gmane.comp.version-control.git/238242/focus=238311.
In this case the cause was a curl error that was fixed in version curl
version 7.34...

I have curl version 7.36 though, in case some of the other output matters:

[normal@laptop tmp]$ curl --version
curl 7.36.0 (x86_64-unknown-linux-gnu) libcurl/7.36.0 OpenSSL/1.0.1g
zlib/1.2.8 libssh2/1.4.3
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp
scp sftp smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate IPv6 Largefile NTLM NTLM_WB SSL libz
TLS-SRP

The curl command to reproduce the since fixed bug (curl --limit-rate 250k
-L http://github.com/raspberrypi/firmware/archive/4ade27942e.tar.gz 
/dev/null) runs without error and exits with a value of 0.

The first response to Stefan's bug report requested the output of the
command with GIT_TRANSPORT_HELPER_DEBUG=1 and strace -f, so I've included
that:

GIT_TRANSPORT...:
https://drive.google.com/file/d/0BxdiDTQp3MYXQWJJaVdydUstbWs/edit?usp=sharing
strace (33M download, 330M uncompressed):
https://drive.google.com/file/d/0BxdiDTQp3MYXb1VKWWtFUDdvbjQ/edit?usp=sharing

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


[RTC/PATCH] Add 'update-branch' hook

2014-04-20 Thread Felipe Contreras
This hook is invoked whenever a branch is updated, either when a branch
is created or updated with 'git branch', or when it's rebased with 'git
rebase'. It receives two parameters; the name of the branch, and the
SHA-1 of the latest commit, additionally, if there was a base commit the
branch was rebased onto, a third parameter contains it.

It can be used to verify the validity of branch names, and also to keep
track of the origin point of a branch, which is otherwise not possible
to find out [1].

[1] http://thread.gmane.org/gmane.comp.version-control.git/198587

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 Documentation/githooks.txt|  9 +
 branch.c  |  6 ++
 builtin/clone.c   |  7 +--
 git-rebase--interactive.sh|  6 +-
 git-rebase.sh |  6 +-
 t/t5408-update-branch-hook.sh | 39 +++
 6 files changed, 69 insertions(+), 4 deletions(-)
 create mode 100755 t/t5408-update-branch-hook.sh

diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt
index d954bf6..9e50697 100644
--- a/Documentation/githooks.txt
+++ b/Documentation/githooks.txt
@@ -381,6 +381,15 @@ rebase::
 The commits are guaranteed to be listed in the order that they were
 processed by rebase.
 
+update-branch
+~
+
+This hook is invoked whenever a branch is updated, either when a branch is
+created or updated with 'git branch', or when it's rebased with 'git rebase'.
+It receives two parameters; the name of the branch, and the SHA-1 of the latest
+commit, additionally, if there was a base commit the branch was rebased onto, a
+third parameter contains it.
+
 
 GIT
 ---
diff --git a/branch.c b/branch.c
index 660097b..c2058d1 100644
--- a/branch.c
+++ b/branch.c
@@ -4,6 +4,7 @@
 #include refs.h
 #include remote.h
 #include commit.h
+#include run-command.h
 
 struct tracking {
struct refspec spec;
@@ -304,6 +305,11 @@ void create_branch(const char *head,
if (real_ref  track)
setup_tracking(ref.buf + 11, real_ref, track, quiet);
 
+   if (run_hook_le(NULL, update-branch, ref.buf + 11, sha1_to_hex(sha1), 
NULL)) {
+   unlock_ref(lock);
+   die(hook 'update-branch' returned error);
+   }
+
if (!dont_change_ref)
if (write_ref_sha1(lock, sha1, msg)  0)
die_errno(_(Failed to write ref));
diff --git a/builtin/clone.c b/builtin/clone.c
index 9b3c04d..6ec96e5 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -581,9 +581,10 @@ static void update_remote_refs(const struct ref *refs,
}
 }
 
-static void update_head(const struct ref *our, const struct ref *remote,
+static int update_head(const struct ref *our, const struct ref *remote,
const char *msg)
 {
+   int err = 0;
if (our  starts_with(our-name, refs/heads/)) {
/* Local default branch link */
create_symref(HEAD, our-name, NULL);
@@ -591,6 +592,7 @@ static void update_head(const struct ref *our, const struct 
ref *remote,
const char *head = skip_prefix(our-name, 
refs/heads/);
update_ref(msg, HEAD, our-old_sha1, NULL, 0, 
DIE_ON_ERR);
install_branch_config(0, head, option_origin, 
our-name);
+   err = run_hook_le(NULL, update-branch, head, 
sha1_to_hex(our-old_sha1), NULL);
}
} else if (our) {
struct commit *c = lookup_commit_reference(our-old_sha1);
@@ -606,6 +608,7 @@ static void update_head(const struct ref *our, const struct 
ref *remote,
update_ref(msg, HEAD, remote-old_sha1,
   NULL, REF_NODEREF, DIE_ON_ERR);
}
+   return err;
 }
 
 static int checkout(void)
@@ -987,7 +990,7 @@ int cmd_clone(int argc, const char **argv, const char 
*prefix)
update_remote_refs(refs, mapped_refs, remote_head_points_at,
   branch_top.buf, reflog_msg.buf, transport, 
!is_local);
 
-   update_head(our_head_points_at, remote_head, reflog_msg.buf);
+   err = update_head(our_head_points_at, remote_head, reflog_msg.buf);
 
transport_unlock_pack(transport);
transport_disconnect(transport);
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 1c41cbd..084dc36 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -631,7 +631,11 @@ do_next () {
git update-ref -m $message $head_name $newhead $orig_head 
git symbolic-ref \
  -m $GIT_REFLOG_ACTION: returning to $head_name \
- HEAD $head_name
+ HEAD $head_name 
+   if test -x $GIT_DIR/hooks/update-branch; then
+   $GIT_DIR/hooks/update-branch $branch_name \
+   $newhead $onto
+   fi
;;
esac