Re: [PATCH] Added get sendmail from .mailrc

2014-01-26 Thread Brilliantov Kirill Vladimirovich
On 2014-01-26 11:34:38, Brilliantov Kirill Vladimirovich wrote:
 On 2014-01-25 22:37:21, Eric Wong wrote:
  
  We should probably avoid a new dependency and also remain consistent
  with the rest of git handles home directories.
  
  Unfortunately, expand_user_path()/git_config_pathname() isn't currently
  exposed to scripters right now...
  
 
 Ok, if new dependency is not allowed I see next ways:
 - add new argument
 - add new configuration parameters

Ok, git support setting path to sendmail-like program via sendemail.smtpserver
configuration option.
It is not very convenient because I need have separated configuration for mail
and git.

--
To unsubscribe from this list: send the line 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] Added get sendmail from .mailrc

2014-01-26 Thread Eric Wong
Brilliantov Kirill Vladimirovich brillian...@inbox.ru wrote:
 On 2014-01-25 22:37:21, Eric Wong wrote:
  Brilliantov Kirill Vladimirovich brillian...@inbox.ru wrote:
   --- a/git-send-email.perl
   +++ b/git-send-email.perl
   @@ -28,6 +28,7 @@ use File::Temp qw/ tempdir tempfile /;
use File::Spec::Functions qw(catfile);
use Error qw(:try);
use Git;
   +use File::HomeDir;
  
  We should probably avoid a new dependency and also remain consistent
  with the rest of git handles home directories.
  
  Unfortunately, expand_user_path()/git_config_pathname() isn't currently
  exposed to scripters right now...
 
 Ok, if new dependency is not allowed I see next ways:

Not saying it's not allowed.  I meant we should probably expose
expand_user_path()/git_config_pathname() C functions to script helpers
(so git-config or git-rev-parse can provide them to sh or perl scripts).
--
To unsubscribe from this list: send the line 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] create HTML for http-protocol.txt

2014-01-26 Thread Thomas Ackermann

This is a reroll of my attempt to create usable HTML for http-protocol.txt.

The first patch addresses Junio's remarks regarding the conversion to better 
ASCIIDOC.
The patch contains some whitespace-only changes so these shouldn't be ignored 
while applying.

The second patch tries to fix one of the TODOs the original author has put into 
the document.


---
Thomas
--
To unsubscribe from this list: send the line 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] create HTML for http-protocol.txt

2014-01-26 Thread Thomas Ackermann
[PATCH 1/2] create HTML for http-protocol.txt

./Documentation/technical/http-protocol.txt was missing from TECH_DOCS in 
Makefile.
Add it and also improve HTML formatting while still retaining good readability 
of the ASCII text:
- Use monospace font instead of italicized or roman font for machine output and 
source text
- Use roman font for things which should be body text
- Use double quotes consistently for want and have commands
- Use uppercase C / S consistently for client / server;
  also use C: / S: instead of (C) / (S) for consistency and
  to avoid having formatted (C) as copyright symbol in HTML
- Use only spaces and not a combination of tabs and spaces for whitespace

Signed-off-by: Thomas Ackermann th.ac...@arcor.de
---
 Documentation/Makefile|   3 +-
 Documentation/technical/http-protocol.txt | 232 +++---
 2 files changed, 120 insertions(+), 115 deletions(-)

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 36c58fc..b19d52a 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -60,7 +60,8 @@ SP_ARTICLES += howto/maintain-git
 API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt 
technical/api-index.txt, $(wildcard technical/api-*.txt)))
 SP_ARTICLES += $(API_DOCS)
 
-TECH_DOCS = technical/index-format
+TECH_DOCS = technical/http-protocol
+TECH_DOCS += technical/index-format
 TECH_DOCS += technical/pack-format
 TECH_DOCS += technical/pack-heuristics
 TECH_DOCS += technical/pack-protocol
diff --git a/Documentation/technical/http-protocol.txt 
b/Documentation/technical/http-protocol.txt
index d21d77d..7f0cf0b 100644
--- a/Documentation/technical/http-protocol.txt
+++ b/Documentation/technical/http-protocol.txt
@@ -20,13 +20,13 @@ URL syntax documented by RFC 1738, so they are of the form:
 
   http://host:port/path?searchpart
 
-Within this documentation the placeholder $GIT_URL will stand for
+Within this documentation the placeholder `$GIT_URL` will stand for
 the http:// repository URL entered by the end-user.
 
-Servers SHOULD handle all requests to locations matching $GIT_URL, as
+Servers SHOULD handle all requests to locations matching `$GIT_URL`, as
 both the smart and dumb HTTP protocols used by Git operate
 by appending additional path components onto the end of the user
-supplied $GIT_URL string.
+supplied `$GIT_URL` string.
 
 An example of a dumb client requesting for a loose object:
 
@@ -43,10 +43,10 @@ An example of a request to a submodule:
   $GIT_URL: http://example.com/git/repo.git/path/submodule.git
   URL request:  http://example.com/git/repo.git/path/submodule.git/info/refs
 
-Clients MUST strip a trailing '/', if present, from the user supplied
-$GIT_URL string to prevent empty path tokens ('//') from appearing
+Clients MUST strip a trailing `/`, if present, from the user supplied
+`$GIT_URL` string to prevent empty path tokens (`//`) from appearing
 in any URL sent to a server.  Compatible clients MUST expand
-'$GIT_URL/info/refs' as 'foo/info/refs' and not 'foo//info/refs'.
+`$GIT_URL/info/refs` as `foo/info/refs` and not `foo//info/refs`.
 
 
 Authentication
@@ -103,14 +103,14 @@ Except where noted, all standard HTTP behavior SHOULD be 
assumed
 by both client and server.  This includes (but is not necessarily
 limited to):
 
-If there is no repository at $GIT_URL, or the resource pointed to by a
-location matching $GIT_URL does not exist, the server MUST NOT respond
-with '200 OK' response.  A server SHOULD respond with
-'404 Not Found', '410 Gone', or any other suitable HTTP status code
+If there is no repository at `$GIT_URL`, or the resource pointed to by a
+location matching `$GIT_URL` does not exist, the server MUST NOT respond
+with `200 OK` response.  A server SHOULD respond with
+`404 Not Found`, `410 Gone`, or any other suitable HTTP status code
 which does not imply the resource exists as requested.
 
-If there is a repository at $GIT_URL, but access is not currently
-permitted, the server MUST respond with the '403 Forbidden' HTTP
+If there is a repository at `$GIT_URL`, but access is not currently
+permitted, the server MUST respond with the `403 Forbidden` HTTP
 status code.
 
 Servers SHOULD support both HTTP 1.0 and HTTP 1.1.
@@ -126,9 +126,9 @@ Servers MAY return ETag and/or Last-Modified headers.
 Clients MAY revalidate cached entities by including If-Modified-Since
 and/or If-None-Match request headers.
 
-Servers MAY return '304 Not Modified' if the relevant headers appear
+Servers MAY return `304 Not Modified` if the relevant headers appear
 in the request and the entity has not changed.  Clients MUST treat
-'304 Not Modified' identical to '200 OK' by reusing the cached entity.
+`304 Not Modified` identical to `200 OK` by reusing the cached entity.
 
 Clients MAY reuse a cached entity without revalidation if the
 Cache-Control and/or Expires header permits caching.  Clients and
@@ -148,7 +148,7 @@ HTTP clients that only support the dumb protocol MUST 

[PATCH 2/2] http-protocol.txt: don't use uppercase for variable names in The Negotiation Algorithm

2014-01-26 Thread Thomas Ackermann

Signed-off-by: Thomas Ackermann th.ac...@arcor.de
---
 Documentation/technical/http-protocol.txt | 45 +++
 1 file changed, 22 insertions(+), 23 deletions(-)

diff --git a/Documentation/technical/http-protocol.txt 
b/Documentation/technical/http-protocol.txt
index 7f0cf0b..90beb32 100644
--- a/Documentation/technical/http-protocol.txt
+++ b/Documentation/technical/http-protocol.txt
@@ -335,7 +335,6 @@ server advertises capability `allow-tip-sha1-in-want`.
   have_list =  *PKT-LINE(have SP id LF)
 
 TODO: Document this further.
-TODO: Don't use uppercase for variable names below.
 
 The Negotiation Algorithm
 ~
@@ -346,15 +345,15 @@ The computation to select the minimal pack proceeds as 
follows
 
 C: Use ref discovery to obtain the advertised refs.
 
-C: Place any object seen into set ADVERTISED.
+C: Place any object seen into set `advertised`.
 
-C: Build an empty set, COMMON, to hold the objects that are later
+C: Build an empty set, `common`, to hold the objects that are later
determined to be on both ends.
 
-C: Build a set, WANT, of the objects from ADVERTISED the client
+C: Build a set, `want`, of the objects from `advertised` the client
wants to fetch, based on what it saw during ref discovery.
 
-C: Start a queue, C_PENDING, ordered by commit time (popping newest
+C: Start a queue, `c_pending`, ordered by commit time (popping newest
first).  Add all client refs.  When a commit is popped from
the queue its parents SHOULD be automatically inserted back.
Commits MUST only enter the queue once.
@@ -363,14 +362,14 @@ C: Start a queue, C_PENDING, ordered by commit time 
(popping newest
 
 C: Send one `$GIT_URL/git-upload-pack` request:
 
-   C: 0032want WANT #1...
-   C: 0032want WANT #2...
+   C: 0032want want #1...
+   C: 0032want want #2...

-   C: 0032have COMMON #1.
-   C: 0032have COMMON #2.
+   C: 0032have common #1.
+   C: 0032have common #2.

-   C: 0032have HAVE #1...
-   C: 0032have HAVE #2...
+   C: 0032have have #1...
+   C: 0032have have #2...

C: 
 
@@ -393,38 +392,38 @@ A single want or have command MUST have one hex 
formatted
 SHA-1 as its value.  Multiple SHA-1s MUST be sent by sending
 multiple commands.
 
-The HAVE list is created by popping the first 32 commits
-from C_PENDING.  Less can be supplied if C_PENDING empties.
+The `have` list is created by popping the first 32 commits
+from `c_pending`.  Less can be supplied if `c_pending` empties.
 
-If the client has sent 256 HAVE commits and has not yet
-received one of those back from S_COMMON, or the client has
-emptied C_PENDING it SHOULD include a done command to let
+If the client has sent 256 have commits and has not yet
+received one of those back from `s_common`, or the client has
+emptied `c_pending` it SHOULD include a done command to let
 the server know it won't proceed:
 
C: 0009done
 
 S: Parse the git-upload-pack request:
 
-Verify all objects in WANT are directly reachable from refs.
+Verify all objects in `want` are directly reachable from refs.
 
 The server MAY walk backwards through history or through
 the reflog to permit slightly stale requests.
 
-If no WANT objects are received, send an error:
+If no want objects are received, send an error:
 TODO: Define error if no want lines are requested.
 
-If any WANT object is not reachable, send an error:
+If any want object is not reachable, send an error:
 TODO: Define error if an invalid want is requested.
 
-Create an empty list, S_COMMON.
+Create an empty list, `s_common`.
 
 If have was sent:
 
 Loop through the objects in the order supplied by the client.
 
 For each object, if the server has the object reachable from
-a ref, add it to S_COMMON.  If a commit is added to S_COMMON,
-do not add any ancestors, even if they also appear in HAVE.
+a ref, add it to `s_common`.  If a commit is added to `s_common`,
+do not add any ancestors, even if they also appear in `have`.
 
 S: Send the git-upload-pack response:
 
@@ -440,7 +439,7 @@ stream 1.  Progress messages from the server side MAY appear
 in stream 2.
 
 Here a closed set of objects is defined to have at least
-one path from every WANT to at least one COMMON object.
+one path from every want to at least one common object.
 
 If the server needs more information, it replies with a
 status continue response:
-- 
1.8.5.2.msysgit.0


---
Thomas
--
To unsubscribe from this list: send the line 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] create HTML for http-protocol.txt

2014-01-26 Thread Thomas Ackermann

./Documentation/technical/http-protocol.txt was missing from TECH_DOCS in 
Makefile.
Add it and also improve HTML formatting while still retaining good readability 
of the ASCII text:
- Use monospace font instead of italicized or roman font for machine output and 
source text
- Use roman font for things which should be body text
- Use double quotes consistently for want and have commands
- Use uppercase C / S consistently for client / server;
  also use C: / S: instead of (C) / (S) for consistency and
  to avoid having formatted (C) as copyright symbol in HTML
- Use only spaces and not a combination of tabs and spaces for whitespace

Signed-off-by: Thomas Ackermann th.ac...@arcor.de
---
 Documentation/Makefile|   3 +-
 Documentation/technical/http-protocol.txt | 232 +++---
 2 files changed, 120 insertions(+), 115 deletions(-)

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 36c58fc..b19d52a 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -60,7 +60,8 @@ SP_ARTICLES += howto/maintain-git
 API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt 
technical/api-index.txt, $(wildcard technical/api-*.txt)))
 SP_ARTICLES += $(API_DOCS)
 
-TECH_DOCS = technical/index-format
+TECH_DOCS = technical/http-protocol
+TECH_DOCS += technical/index-format
 TECH_DOCS += technical/pack-format
 TECH_DOCS += technical/pack-heuristics
 TECH_DOCS += technical/pack-protocol
diff --git a/Documentation/technical/http-protocol.txt 
b/Documentation/technical/http-protocol.txt
index d21d77d..7f0cf0b 100644
--- a/Documentation/technical/http-protocol.txt
+++ b/Documentation/technical/http-protocol.txt
@@ -20,13 +20,13 @@ URL syntax documented by RFC 1738, so they are of the form:
 
   http://host:port/path?searchpart
 
-Within this documentation the placeholder $GIT_URL will stand for
+Within this documentation the placeholder `$GIT_URL` will stand for
 the http:// repository URL entered by the end-user.
 
-Servers SHOULD handle all requests to locations matching $GIT_URL, as
+Servers SHOULD handle all requests to locations matching `$GIT_URL`, as
 both the smart and dumb HTTP protocols used by Git operate
 by appending additional path components onto the end of the user
-supplied $GIT_URL string.
+supplied `$GIT_URL` string.
 
 An example of a dumb client requesting for a loose object:
 
@@ -43,10 +43,10 @@ An example of a request to a submodule:
   $GIT_URL: http://example.com/git/repo.git/path/submodule.git
   URL request:  http://example.com/git/repo.git/path/submodule.git/info/refs
 
-Clients MUST strip a trailing '/', if present, from the user supplied
-$GIT_URL string to prevent empty path tokens ('//') from appearing
+Clients MUST strip a trailing `/`, if present, from the user supplied
+`$GIT_URL` string to prevent empty path tokens (`//`) from appearing
 in any URL sent to a server.  Compatible clients MUST expand
-'$GIT_URL/info/refs' as 'foo/info/refs' and not 'foo//info/refs'.
+`$GIT_URL/info/refs` as `foo/info/refs` and not `foo//info/refs`.
 
 
 Authentication
@@ -103,14 +103,14 @@ Except where noted, all standard HTTP behavior SHOULD be 
assumed
 by both client and server.  This includes (but is not necessarily
 limited to):
 
-If there is no repository at $GIT_URL, or the resource pointed to by a
-location matching $GIT_URL does not exist, the server MUST NOT respond
-with '200 OK' response.  A server SHOULD respond with
-'404 Not Found', '410 Gone', or any other suitable HTTP status code
+If there is no repository at `$GIT_URL`, or the resource pointed to by a
+location matching `$GIT_URL` does not exist, the server MUST NOT respond
+with `200 OK` response.  A server SHOULD respond with
+`404 Not Found`, `410 Gone`, or any other suitable HTTP status code
 which does not imply the resource exists as requested.
 
-If there is a repository at $GIT_URL, but access is not currently
-permitted, the server MUST respond with the '403 Forbidden' HTTP
+If there is a repository at `$GIT_URL`, but access is not currently
+permitted, the server MUST respond with the `403 Forbidden` HTTP
 status code.
 
 Servers SHOULD support both HTTP 1.0 and HTTP 1.1.
@@ -126,9 +126,9 @@ Servers MAY return ETag and/or Last-Modified headers.
 Clients MAY revalidate cached entities by including If-Modified-Since
 and/or If-None-Match request headers.
 
-Servers MAY return '304 Not Modified' if the relevant headers appear
+Servers MAY return `304 Not Modified` if the relevant headers appear
 in the request and the entity has not changed.  Clients MUST treat
-'304 Not Modified' identical to '200 OK' by reusing the cached entity.
+`304 Not Modified` identical to `200 OK` by reusing the cached entity.
 
 Clients MAY reuse a cached entity without revalidation if the
 Cache-Control and/or Expires header permits caching.  Clients and
@@ -148,7 +148,7 @@ HTTP clients that only support the dumb protocol MUST 
discover
 references by making a request for 

Aw: [PATCH 1/2] create HTML for http-protocol.txt

2014-01-26 Thread Thomas Ackermann
 
please ignore this one

- Original Nachricht 
Von: Thomas Ackermann th.ac...@arcor.de
An:  git@vger.kernel.org
Datum:   26.01.2014 13:54
Betreff: [PATCH 1/2] create HTML for http-protocol.txt

 [PATCH 1/2] create HTML for http-protocol.txt
 
 ./Documentation/technical/http-protocol.txt was missing from TECH_DOCS in
 Makefile.
 Add it and also improve HTML formatting while still retaining good
 readability of the ASCII text:
 - Use monospace font instead of italicized or roman font for machine output
 and source text
 - Use roman font for things which should be body text
 - Use double quotes consistently for want and have commands
 - Use uppercase C / S consistently for client / server;
   also use C: / S: instead of (C) / (S) for consistency and
   to avoid having formatted (C) as copyright symbol in HTML
 - Use only spaces and not a combination of tabs and spaces for whitespace
 
 Signed-off-by: Thomas Ackermann th.ac...@arcor.de
 ---
  Documentation/Makefile|   3 +-
  Documentation/technical/http-protocol.txt | 232
 +++---
  2 files changed, 120 insertions(+), 115 deletions(-)
 
 diff --git a/Documentation/Makefile b/Documentation/Makefile
 index 36c58fc..b19d52a 100644
 --- a/Documentation/Makefile
 +++ b/Documentation/Makefile
 @@ -60,7 +60,8 @@ SP_ARTICLES += howto/maintain-git
  API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt
 technical/api-index.txt, $(wildcard technical/api-*.txt)))
  SP_ARTICLES += $(API_DOCS)
  
 -TECH_DOCS = technical/index-format
 +TECH_DOCS = technical/http-protocol
 +TECH_DOCS += technical/index-format
  TECH_DOCS += technical/pack-format
  TECH_DOCS += technical/pack-heuristics
  TECH_DOCS += technical/pack-protocol
 diff --git a/Documentation/technical/http-protocol.txt
 b/Documentation/technical/http-protocol.txt
 index d21d77d..7f0cf0b 100644
 --- a/Documentation/technical/http-protocol.txt
 +++ b/Documentation/technical/http-protocol.txt
 @@ -20,13 +20,13 @@ URL syntax documented by RFC 1738, so they are of the
 form:
  
http://host:port/path?searchpart
  
 -Within this documentation the placeholder $GIT_URL will stand for
 +Within this documentation the placeholder `$GIT_URL` will stand for
  the http:// repository URL entered by the end-user.
  
 -Servers SHOULD handle all requests to locations matching $GIT_URL, as
 +Servers SHOULD handle all requests to locations matching `$GIT_URL`, as
  both the smart and dumb HTTP protocols used by Git operate
  by appending additional path components onto the end of the user
 -supplied $GIT_URL string.
 +supplied `$GIT_URL` string.
  
  An example of a dumb client requesting for a loose object:
  
 @@ -43,10 +43,10 @@ An example of a request to a submodule:
$GIT_URL: http://example.com/git/repo.git/path/submodule.git
URL request: 
 http://example.com/git/repo.git/path/submodule.git/info/refs
  
 -Clients MUST strip a trailing '/', if present, from the user supplied
 -$GIT_URL string to prevent empty path tokens ('//') from appearing
 +Clients MUST strip a trailing `/`, if present, from the user supplied
 +`$GIT_URL` string to prevent empty path tokens (`//`) from appearing
  in any URL sent to a server.  Compatible clients MUST expand
 -'$GIT_URL/info/refs' as 'foo/info/refs' and not 'foo//info/refs'.
 +`$GIT_URL/info/refs` as `foo/info/refs` and not `foo//info/refs`.
  
  
  Authentication
 @@ -103,14 +103,14 @@ Except where noted, all standard HTTP behavior SHOULD
 be assumed
  by both client and server.  This includes (but is not necessarily
  limited to):
  
 -If there is no repository at $GIT_URL, or the resource pointed to by a
 -location matching $GIT_URL does not exist, the server MUST NOT respond
 -with '200 OK' response.  A server SHOULD respond with
 -'404 Not Found', '410 Gone', or any other suitable HTTP status code
 +If there is no repository at `$GIT_URL`, or the resource pointed to by a
 +location matching `$GIT_URL` does not exist, the server MUST NOT respond
 +with `200 OK` response.  A server SHOULD respond with
 +`404 Not Found`, `410 Gone`, or any other suitable HTTP status code
  which does not imply the resource exists as requested.
  
 -If there is a repository at $GIT_URL, but access is not currently
 -permitted, the server MUST respond with the '403 Forbidden' HTTP
 +If there is a repository at `$GIT_URL`, but access is not currently
 +permitted, the server MUST respond with the `403 Forbidden` HTTP
  status code.
  
  Servers SHOULD support both HTTP 1.0 and HTTP 1.1.
 @@ -126,9 +126,9 @@ Servers MAY return ETag and/or Last-Modified headers.
  Clients MAY revalidate cached entities by including If-Modified-Since
  and/or If-None-Match request headers.
  
 -Servers MAY return '304 Not Modified' if the relevant headers appear
 +Servers MAY return `304 Not Modified` if the relevant headers appear
  in the request and the entity has not changed.  Clients MUST treat
 -'304 Not Modified' identical to '200 

[PATCH 0/2] in-tree symlink handling with absolute paths

2014-01-26 Thread Martin Erik Werner
On Wed, 2014-01-15 at 13:48 +0100, Martin Erik Werner wrote:
 If git-mv is provided absolute paths when moving symlinks, it tries to
 dereference them and (attempts to) move the symlink target rather than the
 symlink itself, this seems like a quite odd behaviour since it's inconsistent
 with how git-mv works with symlinks if given relative paths, and I'm thinking
 it might be a bug, since it not documented in the git-mv manpage.

I've done a bit more digging into this: The issue applies to pretty much all
commands which can be given paths to files which are present in the work tree,
so add, cat-file, rev-list, etc.

I've written a test and a fix which seems to do the right thing.

Martin Erik Werner (2):
  t0060: Add test for manipulating symlinks via absolute paths
  setup: Don't dereference in-tree symlinks for absolute paths

 setup.c   | 54 ---
 t/t0060-path-utils.sh |  7 +++
 2 files changed, 41 insertions(+), 20 deletions(-)
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] setup: Don't dereference in-tree symlinks for absolute paths

2014-01-26 Thread Martin Erik Werner
The prefix_path_gently() function currently applies real_path to
everything if given an absolute path, dereferencing symlinks both
outside and inside the work tree. In order to manipulate symliks in the
work tree using absolute paths, symlinks should only be dereferenced
outside the work tree.

Modify prefix_path_gently() to first normalize the path in order to
make sure path levels are separated by '/', then use this separator to
check the real path of each level of the path until it has found the
length that corresponds to the work tree.

For absolute paths, the function did not, nor does now do, any actual
prefixing, hence we simply remove the path corresponding to the work
tree and return the remaining in-tree part of the path.

Fixes t0060-82.

Signed-off-by: Martin Erik Werner martinerikwer...@gmail.com
---
 setup.c   | 54 ---
 t/t0060-path-utils.sh |  2 +-
 2 files changed, 35 insertions(+), 21 deletions(-)

diff --git a/setup.c b/setup.c
index 6c3f85f..bec587e 100644
--- a/setup.c
+++ b/setup.c
@@ -22,11 +22,41 @@ char *prefix_path_gently(const char *prefix, int len,
const char *orig = path;
char *sanitized;
if (is_absolute_path(orig)) {
-   const char *temp = real_path(path);
-   sanitized = xmalloc(len + strlen(temp) + 1);
-   strcpy(sanitized, temp);
+   char npath[strlen(path)];
if (remaining_prefix)
*remaining_prefix = 0;
+   if (normalize_path_copy_len(npath, path, remaining_prefix))
+   return NULL;
+   const char *work_tree = get_git_work_tree();
+   if (!work_tree)
+   return NULL;
+   struct string_list list = STRING_LIST_INIT_DUP;
+   string_list_split(list, npath, '/', -1);
+
+   char wtpart[strlen(npath) + 1];
+   int i = 0;
+   int match = 0;
+   strcpy(wtpart, list.items[i++].string);
+   strcpy(wtpart, /);
+   if (strcmp(real_path(wtpart), work_tree) == 0) {
+   match = 1;
+   } else {
+   while (i  list.nr) {
+   strcat(wtpart, list.items[i++].string);
+   if (strcmp(real_path(wtpart), work_tree) == 0) {
+   match = 1;
+   break;
+   }
+   strcat(wtpart, /);
+   }
+   }
+   string_list_clear(list, 0);
+   if (!match)
+   return NULL;
+
+   size_t wtpartlen = strlen(wtpart);
+   sanitized = xmalloc(strlen(npath) - wtpartlen);
+   strcpy(sanitized, npath + wtpartlen + 1);
} else {
sanitized = xmalloc(len + strlen(path) + 1);
if (len)
@@ -34,26 +64,10 @@ char *prefix_path_gently(const char *prefix, int len,
strcpy(sanitized + len, path);
if (remaining_prefix)
*remaining_prefix = len;
-   }
-   if (normalize_path_copy_len(sanitized, sanitized, remaining_prefix))
-   goto error_out;
-   if (is_absolute_path(orig)) {
-   size_t root_len, len, total;
-   const char *work_tree = get_git_work_tree();
-   if (!work_tree)
-   goto error_out;
-   len = strlen(work_tree);
-   root_len = offset_1st_component(work_tree);
-   total = strlen(sanitized) + 1;
-   if (strncmp(sanitized, work_tree, len) ||
-   (len  root_len  sanitized[len] != '\0'  sanitized[len] 
!= '/')) {
-   error_out:
+   if (normalize_path_copy_len(sanitized, sanitized, 
remaining_prefix)) {
free(sanitized);
return NULL;
}
-   if (sanitized[len] == '/')
-   len++;
-   memmove(sanitized, sanitized + len, total - len);
}
return sanitized;
 }
diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh
index 3a0677a..03a12ac 100755
--- a/t/t0060-path-utils.sh
+++ b/t/t0060-path-utils.sh
@@ -190,7 +190,7 @@ test_expect_success SYMLINKS 'real path works on symlinks' '
test $sym = $(test-path-utils real_path $dir2/syml)
 '
 
-test_expect_failure SYMLINKS 'prefix_path works with work tree symlinks' '
+test_expect_success SYMLINKS 'prefix_path works with work tree symlinks' '
 
ln -s target symlink 
test $(test-path-utils prefix_path prefix $(pwd)/symlink) = 
symlink
-- 
1.8.5.2

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

[PATCH 1/2] t0060: Add test for manipulating symlinks via absolute paths

2014-01-26 Thread Martin Erik Werner
When symlinks in the working tree are manipulated using the absolute
path, git dereferences them, and tries to manipulate the link target
instead.

This is a regression introduced by 18e051a:
  setup: translate symlinks in filename when using absolute paths
(which did not take symlinks in the work tree into consideration).

Add a known-breakage tests using the prefix_path function, which
currently uses real_path, causing the dereference.

Signed-off-by: Martin Erik Werner martinerikwer...@gmail.com
---
 t/t0060-path-utils.sh | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh
index 07c10c8..3a0677a 100755
--- a/t/t0060-path-utils.sh
+++ b/t/t0060-path-utils.sh
@@ -190,6 +190,13 @@ test_expect_success SYMLINKS 'real path works on symlinks' 
'
test $sym = $(test-path-utils real_path $dir2/syml)
 '
 
+test_expect_failure SYMLINKS 'prefix_path works with work tree symlinks' '
+
+   ln -s target symlink 
+   test $(test-path-utils prefix_path prefix $(pwd)/symlink) = 
symlink
+
+'
+
 relative_path /foo/a/b/c/  /foo/a/b/   c/
 relative_path /foo/a/b/c/  /foo/a/bc/
 relative_path /foo/a//b//c////foo/a/b//c/  POSIX
-- 
1.8.5.2

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


[TEST EMAIL] Testing rk/send-email-ssl-cert in pu

2014-01-26 Thread Ramkumar Ramachandra
Hi,

This email tests that 01645b7 (send-email: /etc/ssl/certs/ directory
may not be usable as ca_path, 2014-01-15) doesn't cause a regression.

Ram
--
To unsubscribe from this list: send the line 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] send-email: If the ca path is not specified, use the defaults

2014-01-26 Thread Ramkumar Ramachandra
Junio C Hamano wrote:
 This change could introduce a regression for people on a platform
 whose certificate directory is /etc/ssl/certs but its IO::Socket:SSL
 somehow fails to use it as SSL_ca_path without being told.

I can confirm that my git-send-email doesn't regress to the
pre-35035bbf state; my certificate directory is /etc/ssl/certs. I'm
somewhat surprised that IO::Socket::SSL picks the right file/
directory on every platform without being told explicitly. This change
definitely looks like the right fix.

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


[PATCH v3 14/17] trailer: add tests for trailer command

2014-01-26 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 t/t7513-interpret-trailers.sh | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/t/t7513-interpret-trailers.sh b/t/t7513-interpret-trailers.sh
index f5ef81f..2d50b7a 100755
--- a/t/t7513-interpret-trailers.sh
+++ b/t/t7513-interpret-trailers.sh
@@ -212,4 +212,31 @@ test_expect_success 'with input from stdin' '
test_cmp expected actual
 '
 
+test_expect_success 'with simple command' '
+   git config trailer.sign.key Signed-off-by:  
+   git config trailer.sign.where after 
+   git config trailer.sign.ifExist addIfDifferentNeighbor 
+   git config trailer.sign.command echo \A U Thor 
aut...@example.com\ 
+   cat complex_message_body expected 
+   printf Fixes: \nAcked-by= \nReviewed-by: \nSigned-off-by: 
\nSigned-off-by: A U Thor aut...@example.com\n expected 
+   git interpret-trailers review: fix=22  complex_message actual 
+   test_cmp expected actual
+'
+
+test_expect_success 'setup a commit' '
+   echo Content of the first commit.  a.txt 
+   git add a.txt 
+   git commit -m Add file a.txt
+'
+
+test_expect_success 'with command using $ARG' '
+   git config trailer.fix.ifExist overwrite 
+   git config trailer.fix.command git log -1 --oneline --format=\%h 
(%s)\ --abbrev-commit --abbrev=14 \$ARG 
+   FIXED=$(git log -1 --oneline --format=%h (%s) --abbrev-commit 
--abbrev=14 HEAD) 
+   cat complex_message_body expected 
+   printf Fixes: $FIXED\nAcked-by= \nReviewed-by: \nSigned-off-by: 
\nSigned-off-by: A U Thor aut...@example.com\n expected 
+   git interpret-trailers review: fix=HEAD  complex_message actual 
+   test_cmp expected actual
+'
+
 test_done
-- 
1.8.5.2.201.gacc5987


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


[PATCH v3 16/17] trailer: add tests for commands using env variables

2014-01-26 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 t/t7513-interpret-trailers.sh | 20 
 1 file changed, 20 insertions(+)

diff --git a/t/t7513-interpret-trailers.sh b/t/t7513-interpret-trailers.sh
index 2d50b7a..00894a8 100755
--- a/t/t7513-interpret-trailers.sh
+++ b/t/t7513-interpret-trailers.sh
@@ -223,6 +223,26 @@ test_expect_success 'with simple command' '
test_cmp expected actual
 '
 
+test_expect_success 'with command using commiter information' '
+   git config trailer.sign.ifExist addIfDifferent 
+   git config trailer.sign.command echo \\$GIT_COMMITTER_NAME 
\$GIT_COMMITTER_EMAIL\ 
+   cat complex_message_body expected 
+   printf Fixes: \nAcked-by= \nReviewed-by: \nSigned-off-by: 
\nSigned-off-by: C O Mitter commit...@example.com\n expected 
+   git interpret-trailers review: fix=22  complex_message actual 
+   test_cmp expected actual
+'
+
+test_expect_success 'with command using author information' '
+   git config trailer.sign.key Signed-off-by:  
+   git config trailer.sign.where after 
+   git config trailer.sign.ifExist addIfDifferentNeighbor 
+   git config trailer.sign.command echo \\$GIT_AUTHOR_NAME 
\$GIT_AUTHOR_EMAIL\ 
+   cat complex_message_body expected 
+   printf Fixes: \nAcked-by= \nReviewed-by: \nSigned-off-by: 
\nSigned-off-by: A U Thor aut...@example.com\n expected 
+   git interpret-trailers review: fix=22  complex_message actual 
+   test_cmp expected actual
+'
+
 test_expect_success 'setup a commit' '
echo Content of the first commit.  a.txt 
git add a.txt 
-- 
1.8.5.2.201.gacc5987


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


[PATCH v3 06/17] trailer: parse trailers from input file

2014-01-26 Thread Christian Couder
This patch reads trailers from an input file, parses
them and puts the result into a doubly linked list.

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 trailer.c | 62 ++
 1 file changed, 62 insertions(+)

diff --git a/trailer.c b/trailer.c
index 89377f2..9ea08a7 100644
--- a/trailer.c
+++ b/trailer.c
@@ -440,3 +440,65 @@ static struct trailer_item *process_command_line_args(int 
argc, const char **arg
 
return arg_tok_first;
 }
+
+static struct strbuf **read_input_file(const char *infile)
+{
+   struct strbuf sb = STRBUF_INIT;
+
+   if (strbuf_read_file(sb, infile, 0)  0)
+   die_errno(_(could not read input file '%s'), infile);
+
+   return strbuf_split(sb, '\n');
+}
+
+/*
+ * Return the the (0 based) index of the first trailer line
+ * or the line count if there are no trailers.
+ */
+static int find_trailer_start(struct strbuf **lines)
+{
+   int count, start, empty = 1;
+
+   /* Get the line count */
+   for (count = 0; lines[count]; count++);
+
+   /*
+* Get the start of the trailers by looking starting from the end
+* for a line with only spaces before lines with one ':'.
+*/
+   for (start = count - 1; start = 0; start--) {
+   if (strbuf_isspace(lines[start])) {
+   if (empty)
+   continue;
+   return start + 1;
+   }
+   if (strchr(lines[start]-buf, ':')) {
+   if (empty)
+   empty = 0;
+   continue;
+   }
+   return count;
+   }
+
+   return empty ? count : start + 1;
+}
+
+static void process_input_file(const char *infile,
+  struct trailer_item **infile_tok_first,
+  struct trailer_item **infile_tok_last)
+{
+   struct strbuf **lines = read_input_file(infile);
+   int start = find_trailer_start(lines);
+   int i;
+
+   /* Print non trailer lines as is */
+   for (i = 0; lines[i]  i  start; i++) {
+   printf(%s, lines[i]-buf);
+   }
+
+   /* Parse trailer lines */
+   for (i = start; lines[i]; i++) {
+   struct trailer_item *new = create_trailer_item(lines[i]-buf);
+   add_trailer_item(infile_tok_first, infile_tok_last, new);
+   }
+}
-- 
1.8.5.2.201.gacc5987


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


[PATCH v3 12/17] strbuf: add strbuf_replace()

2014-01-26 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 strbuf.c | 7 +++
 strbuf.h | 3 +++
 2 files changed, 10 insertions(+)

diff --git a/strbuf.c b/strbuf.c
index 2124bb8..e45e513 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -197,6 +197,13 @@ void strbuf_splice(struct strbuf *sb, size_t pos, size_t 
len,
strbuf_setlen(sb, sb-len + dlen - len);
 }
 
+void strbuf_replace(struct strbuf *sb, const char *a, const char *b)
+{
+   char *ptr = strstr(sb-buf, a);
+   if (ptr)
+   strbuf_splice(sb, ptr - sb-buf, strlen(a), b, strlen(b));
+}
+
 void strbuf_insert(struct strbuf *sb, size_t pos, const void *data, size_t len)
 {
strbuf_splice(sb, pos, 0, data, len);
diff --git a/strbuf.h b/strbuf.h
index 02bff3a..38faf70 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -111,6 +111,9 @@ extern void strbuf_remove(struct strbuf *, size_t pos, 
size_t len);
 extern void strbuf_splice(struct strbuf *, size_t pos, size_t len,
   const void *, size_t);
 
+/* first occurence of a replaced with b */
+extern void strbuf_replace(struct strbuf *, const char *a, const char *b);
+
 extern void strbuf_add_commented_lines(struct strbuf *out, const char *buf, 
size_t size);
 
 extern void strbuf_add(struct strbuf *, const void *, size_t);
-- 
1.8.5.2.201.gacc5987


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


[PATCH v3 17/17] Documentation: add documentation for 'git interpret-trailers'

2014-01-26 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 Documentation/git-interpret-trailers.txt | 137 +++
 1 file changed, 137 insertions(+)
 create mode 100644 Documentation/git-interpret-trailers.txt

diff --git a/Documentation/git-interpret-trailers.txt 
b/Documentation/git-interpret-trailers.txt
new file mode 100644
index 000..f74843e
--- /dev/null
+++ b/Documentation/git-interpret-trailers.txt
@@ -0,0 +1,137 @@
+git-interpret-trailers(1)
+=
+
+NAME
+
+git-interpret-trailers - help add stuctured information into commit messages
+
+SYNOPSIS
+
+[verse]
+'git interpret-trailers' [--trim-empty] [--infile=file] [token[=value]...]
+
+DESCRIPTION
+---
+Help add RFC 822 like headers, called 'trailers', at the end of the
+otherwise free-form part of a commit message.
+
+Unless `--infile=file` is used, this command is a filter. It reads the
+standard input for a commit message and apply the `token` arguments,
+if any, to this message. The resulting message is emited on the
+standard output.
+
+Some configuration variables control the way the `token` arguments are
+applied to the message and the way any existing trailer in the message
+is changed. They also make it possible to automatically add some
+trailers.
+
+By default, a 'token=value' or 'token:value' argument will be added
+only if no trailer with the same (token, value) pair is already in the
+message. The 'token' and 'value' parts will be trimmed to remove
+starting and trailing white spaces, and the resulting trimmed 'token'
+and 'value' will appear in the message like this:
+
+
+token: value
+
+
+By default, if there are already trailers with the same 'token' the
+trailer will appear just after the last trailer with the same
+'token'. Otherwise it will appear at the end of the message.
+
+Note that 'trailers' do not follow and are not intended to follow many
+rules that are in RFC 822. For example they do not follow the line
+breaking rules, the encoding rules and probably many other rules.
+
+Trailers have become a de facto standard way to add helpful structured
+information into commit messages. For example the well known
+Signed-off-by:  trailer is used by many projects like the Linux
+kernel and Git.
+
+OPTIONS
+---
+--trim-empty::
+   If the 'value' part of any trailer contains onlywhite spaces,
+   the whole trailer will be removed from the resulting message.
+
+infile=file::
+   Read the commit message from `file` instead of the standard
+   input.
+
+CONFIGURATION VARIABLES
+---
+
+trailer.token.key::
+   This 'key' will be used instead of 'token' in the
+   trailer. After some alphanumeric characters, it can contain
+   some non alphanumeric characters like ':', '=' or '#' that will
+   be used instead of ':' to separate the token from the value in
+   the trailer, though the default ':' is more standard.
+
+trailer.token.where::
+   This can be either `after`, which is the default, or
+   `before`. If it is `before`, then a trailer with the specified
+   token, will appear before, instead of after, other trailers
+   with the same token, or otherwise at the beginning, instead of
+   at the end, of all the trailers.
+
+trailer.token.ifexist::
+   This option makes it possible to chose what action will be
+   performed when there is already at least one trailer with the
+   same token in the message.
++
+The valid values for this option are: `addIfDifferent` (this is the
+default), `addIfDifferentNeighbor`, `add`, `overwrite` or `doNothing`.
++
+With `addIfDifferent`, a new trailer will be added only if no trailer
+with the same (token, value) pair is already in the message.
++
+With `addIfDifferentNeighbor`, a new trailer will be added only if no
+trailer with the same (token, value) pair is above or below the line
+where the new trailer will be added.
++
+With `add`, a new trailer will be added, even if some trailers with
+the same (token, value) pair are already in the message.
++
+With `overwrite`, the new trailer will overwrite an existing trailer
+with the same token.
++
+With `doNothing`, nothing will be done, that is no new trailer will be
+added if there is already one with the same token in the message.
+
+trailer.token.ifmissing::
+   This option makes it possible to chose what action will be
+   performed when there is not yet any trailer with the same
+   token in the message.
++
+The valid values for this option are: `add` (this is the default) and
+`doNothing`.
++
+With `add`, a new trailer will be added.
++
+With `doNothing`, nothing will be done.
+
+trailer.token.command::
+   This option can be used to specify a shell command that will
+   be used to automatically add or modify a trailer with the
+   specified 'token'.
++
+When this 

[PATCH v3 02/17] trailer: process trailers from file and arguments

2014-01-26 Thread Christian Couder
This patch implements the logic that process trailers
from file and arguments.

At the beginning trailers from file are in their own
infile_tok doubly linked list, and trailers from
arguments are in their own arg_tok doubly linked list.

The lists are traversed and when an arg_tok should be
applied, it is removed from its list and inserted
into the infile_tok list.

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 trailer.c | 189 ++
 1 file changed, 189 insertions(+)

diff --git a/trailer.c b/trailer.c
index d80d047..d88de3f 100644
--- a/trailer.c
+++ b/trailer.c
@@ -45,3 +45,192 @@ static size_t alnum_len(const char *buf, size_t len) {
while (--len = 0  !isalnum(buf[len]));
return len + 1;
 }
+
+static void add_arg_to_infile(struct trailer_item *infile_tok,
+ struct trailer_item *arg_tok)
+{
+   if (arg_tok-conf-where == WHERE_AFTER) {
+   arg_tok-next = infile_tok-next;
+   infile_tok-next = arg_tok;
+   arg_tok-previous = infile_tok;
+   if (arg_tok-next)
+   arg_tok-next-previous = arg_tok;
+   } else {
+   arg_tok-previous = infile_tok-previous;
+   infile_tok-previous = arg_tok;
+   arg_tok-next = infile_tok;
+   if (arg_tok-previous)
+   arg_tok-previous-next = arg_tok;
+   }
+}
+
+static int check_if_different(struct trailer_item *infile_tok,
+ struct trailer_item *arg_tok,
+ int alnum_len, int check_all)
+{
+   enum action_where where = arg_tok-conf-where;
+   do {
+   if (!infile_tok)
+   return 1;
+   if (same_trailer(infile_tok, arg_tok, alnum_len))
+   return 0;
+   /*
+* if we want to add a trailer after another one,
+* we have to check those before this one
+*/
+   infile_tok = (where == WHERE_AFTER) ? infile_tok-previous : 
infile_tok-next;
+   } while (check_all);
+   return 1;
+}
+
+static void apply_arg_if_exist(struct trailer_item *infile_tok,
+  struct trailer_item *arg_tok,
+  int alnum_len)
+{
+   switch(arg_tok-conf-if_exist) {
+   case EXIST_DO_NOTHING:
+   free(arg_tok);
+   break;
+   case EXIST_OVERWRITE:
+   free((char *)infile_tok-value);
+   infile_tok-value = xstrdup(arg_tok-value);
+   free(arg_tok);
+   break;
+   case EXIST_ADD:
+   add_arg_to_infile(infile_tok, arg_tok);
+   break;
+   case EXIST_ADD_IF_DIFFERENT:
+   if (check_if_different(infile_tok, arg_tok, alnum_len, 1))
+   add_arg_to_infile(infile_tok, arg_tok);
+   else
+   free(arg_tok);
+   break;
+   case EXIST_ADD_IF_DIFFERENT_NEIGHBOR:
+   if (check_if_different(infile_tok, arg_tok, alnum_len, 0))
+   add_arg_to_infile(infile_tok, arg_tok);
+   else
+   free(arg_tok);
+   break;
+   }
+}
+
+static void remove_from_list(struct trailer_item *item,
+struct trailer_item **first)
+{
+   if (item-next)
+   item-next-previous = item-previous;
+   if (item-previous)
+   item-previous-next = item-next;
+   else
+   *first = item-next;
+}
+
+static struct trailer_item *remove_first(struct trailer_item **first)
+{
+   struct trailer_item *item = *first;
+   *first = item-next;
+   if (item-next) {
+   item-next-previous = NULL;
+   item-next = NULL;
+   }
+   return item;
+}
+
+static void process_infile_tok(struct trailer_item *infile_tok,
+  struct trailer_item **arg_tok_first,
+  enum action_where where)
+{
+   struct trailer_item *arg_tok;
+   struct trailer_item *next_arg;
+
+   int tok_alnum_len = alnum_len(infile_tok-token, 
strlen(infile_tok-token));
+   for (arg_tok = *arg_tok_first; arg_tok; arg_tok = next_arg) {
+   next_arg = arg_tok-next;
+   if (same_token(infile_tok, arg_tok, tok_alnum_len) 
+   arg_tok-conf-where == where) {
+   /* Remove arg_tok from list */
+   remove_from_list(arg_tok, arg_tok_first);
+   /* Apply arg */
+   apply_arg_if_exist(infile_tok, arg_tok, tok_alnum_len);
+   /*
+* If arg has been added to infile,
+* then we need to process it too now.
+*/
+   if ((where == WHERE_AFTER ? 

[PATCH v3 13/17] trailer: execute command from 'trailer.name.command'

2014-01-26 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 trailer.c | 56 
 1 file changed, 56 insertions(+)

diff --git a/trailer.c b/trailer.c
index 6eec3ce..dc81a01 100644
--- a/trailer.c
+++ b/trailer.c
@@ -1,4 +1,5 @@
 #include cache.h
+#include run-command.h
 /*
  * Copyright (c) 2013 Christian Couder chrisc...@tuxfamily.org
  */
@@ -12,11 +13,14 @@ struct conf_info {
char *name;
char *key;
char *command;
+   unsigned command_uses_arg : 1;
enum action_where where;
enum action_if_exist if_exist;
enum action_if_missing if_missing;
 };
 
+#define TRAILER_ARG_STRING $ARG
+
 struct trailer_item {
struct trailer_item *previous;
struct trailer_item *next;
@@ -368,6 +372,7 @@ static int git_trailer_config(const char *conf_key, const 
char *value, void *cb)
if (conf-command)
warning(_(more than one %s), orig_conf_key);
conf-command = xstrdup(value);
+   conf-command_uses_arg = !!strstr(conf-command, 
TRAILER_ARG_STRING);
} else if (type == TRAILER_WHERE) {
if (set_where(conf, value))
warning(_(unknown value '%s' for key '%s'), 
value, orig_conf_key);
@@ -400,6 +405,45 @@ static void parse_trailer(struct strbuf *tok, struct 
strbuf *val, const char *tr
}
 }
 
+static int read_from_command(struct child_process *cp, struct strbuf *buf)
+{
+   if (run_command(cp))
+   return error(running trailer command '%s' failed, 
cp-argv[0]);
+   if (strbuf_read(buf, cp-out, 1024)  1)
+   return error(reading from trailer command '%s' failed, 
cp-argv[0]);
+   strbuf_trim(buf);
+   return 0;
+}
+
+static const char *apply_command(const char *command, const char *arg)
+{
+   struct strbuf cmd = STRBUF_INIT;
+   struct strbuf buf = STRBUF_INIT;
+   struct child_process cp;
+   const char *argv[] = {NULL, NULL};
+   const char *result = ;
+
+   strbuf_addstr(cmd, command);
+   if (arg)
+   strbuf_replace(cmd, TRAILER_ARG_STRING, arg);
+
+   argv[0] = cmd.buf;
+   memset(cp, 0, sizeof(cp));
+   cp.argv = argv;
+   cp.env = local_repo_env;
+   cp.no_stdin = 1;
+   cp.out = -1;
+   cp.use_shell = 1;
+
+   if (read_from_command(cp, buf))
+   strbuf_release(buf);
+   else
+   result = strbuf_detach(buf, NULL);
+
+   strbuf_release(cmd);
+   return result;
+}
+
 static struct trailer_item *new_trailer_item(struct trailer_item *conf_item,
 const char* tok, const char* val)
 {
@@ -409,6 +453,8 @@ static struct trailer_item *new_trailer_item(struct 
trailer_item *conf_item,
if (conf_item) {
new-conf = conf_item-conf;
new-token = xstrdup(conf_item-conf-key);
+   if (conf_item-conf-command_uses_arg || !val)
+   new-value = apply_command(conf_item-conf-command, 
val);
} else {
new-conf = xcalloc(sizeof(struct conf_info), 1);
new-token = tok;
@@ -459,12 +505,22 @@ static struct trailer_item *process_command_line_args(int 
argc, const char **arg
int i;
struct trailer_item *arg_tok_first = NULL;
struct trailer_item *arg_tok_last = NULL;
+   struct trailer_item *item;
 
for (i = 0; i  argc; i++) {
struct trailer_item *new = create_trailer_item(argv[i]);
add_trailer_item(arg_tok_first, arg_tok_last, new);
}
 
+   /* Add conf commands that don't use $ARG */
+   for (item = first_conf_item; item; item = item-next) {
+   if (item-conf-command  !item-conf-command_uses_arg)
+   {
+   struct trailer_item *new = new_trailer_item(item, NULL, 
NULL);
+   add_trailer_item(arg_tok_first, arg_tok_last, new);
+   }
+   }
+
return arg_tok_first;
 }
 
-- 
1.8.5.2.201.gacc5987


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


[PATCH v3 07/17] trailer: put all the processing together and print

2014-01-26 Thread Christian Couder
This patch adds the process_trailers() function that
calls all the previously added processing functions
and then prints the results on the standard output.

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 trailer.c | 40 
 1 file changed, 40 insertions(+)

diff --git a/trailer.c b/trailer.c
index 9ea08a7..2678b3e 100644
--- a/trailer.c
+++ b/trailer.c
@@ -48,6 +48,26 @@ static size_t alnum_len(const char *buf, size_t len) {
return len + 1;
 }
 
+static void print_tok_val(const char *tok, const char *val)
+{
+   char c = tok[strlen(tok) - 1];
+   if (isalnum(c))
+   printf(%s: %s\n, tok, val);
+   else if (isspace(c) || c == '#')
+   printf(%s%s\n, tok, val);
+   else
+   printf(%s %s\n, tok, val);
+}
+
+static void print_all(struct trailer_item *first, int trim_empty)
+{
+   struct trailer_item *item;
+   for (item = first; item; item = item-next) {
+   if (!trim_empty || strlen(item-value)  0)
+   print_tok_val(item-token, item-value);
+   }
+}
+
 static void add_arg_to_infile(struct trailer_item *infile_tok,
  struct trailer_item *arg_tok)
 {
@@ -502,3 +522,23 @@ static void process_input_file(const char *infile,
add_trailer_item(infile_tok_first, infile_tok_last, new);
}
 }
+
+void process_trailers(const char *infile, int trim_empty, int argc, const char 
**argv)
+{
+   struct trailer_item *infile_tok_first = NULL;
+   struct trailer_item *infile_tok_last = NULL;
+   struct trailer_item *arg_tok_first;
+
+   git_config(git_trailer_config, NULL);
+
+   /* Print the non trailer part of infile */
+   if (infile) {
+   process_input_file(infile, infile_tok_first, infile_tok_last);
+   }
+
+   arg_tok_first = process_command_line_args(argc, argv);
+
+   process_trailers_lists(infile_tok_first, infile_tok_last, 
arg_tok_first);
+
+   print_all(infile_tok_first, trim_empty);
+}
-- 
1.8.5.2.201.gacc5987


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


[PATCH v3 11/17] trailer: add new_trailer_item() function

2014-01-26 Thread Christian Couder
This is a small refactoring to prepare for the next steps.

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 trailer.c | 31 +++
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/trailer.c b/trailer.c
index d581371..6eec3ce 100644
--- a/trailer.c
+++ b/trailer.c
@@ -400,11 +400,27 @@ static void parse_trailer(struct strbuf *tok, struct 
strbuf *val, const char *tr
}
 }
 
+static struct trailer_item *new_trailer_item(struct trailer_item *conf_item,
+const char* tok, const char* val)
+{
+   struct trailer_item *new = xcalloc(sizeof(struct trailer_item), 1);
+   new-value = val;
+
+   if (conf_item) {
+   new-conf = conf_item-conf;
+   new-token = xstrdup(conf_item-conf-key);
+   } else {
+   new-conf = xcalloc(sizeof(struct conf_info), 1);
+   new-token = tok;
+   }
+
+   return new;
+}
+
 static struct trailer_item *create_trailer_item(const char *string)
 {
struct strbuf tok = STRBUF_INIT;
struct strbuf val = STRBUF_INIT;
-   struct trailer_item *new;
struct trailer_item *item;
int tok_alnum_len;
 
@@ -416,21 +432,12 @@ static struct trailer_item *create_trailer_item(const 
char *string)
for (item = first_conf_item; item; item = item-next) {
if (!strncasecmp(tok.buf, item-conf-key, tok_alnum_len) ||
!strncasecmp(tok.buf, item-conf-name, tok_alnum_len)) {
-   new = xcalloc(sizeof(struct trailer_item), 1);
-   new-conf = item-conf;
-   new-token = xstrdup(item-conf-key);
-   new-value = strbuf_detach(val, NULL);
strbuf_release(tok);
-   return new;
+   return new_trailer_item(item, NULL, strbuf_detach(val, 
NULL));
}
}
 
-   new = xcalloc(sizeof(struct trailer_item), 1);
-   new-conf = xcalloc(sizeof(struct conf_info), 1);
-   new-token = strbuf_detach(tok, NULL);
-   new-value = strbuf_detach(val, NULL);
-
-   return new;
+   return new_trailer_item(NULL, strbuf_detach(tok, NULL), 
strbuf_detach(val, NULL));;
 }
 
 static void add_trailer_item(struct trailer_item **first,
-- 
1.8.5.2.201.gacc5987


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


[PATCH v3 03/17] trailer: read and process config information

2014-01-26 Thread Christian Couder
This patch implements reading the configuration
to get trailer information, and then processing
it and storing it in a doubly linked list.

The config information is stored in the list
whose first item is pointed to by:

static struct trailer_item *first_conf_item;

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 trailer.c | 129 ++
 1 file changed, 129 insertions(+)

diff --git a/trailer.c b/trailer.c
index d88de3f..e7d8244 100644
--- a/trailer.c
+++ b/trailer.c
@@ -25,6 +25,8 @@ struct trailer_item {
struct conf_info *conf;
 };
 
+static struct trailer_item *first_conf_item;
+
 static int same_token(struct trailer_item *a, struct trailer_item *b, int 
alnum_len)
 {
return !strncasecmp(a-token, b-token, alnum_len);
@@ -234,3 +236,130 @@ static void process_trailers_lists(struct trailer_item 
**infile_tok_first,
apply_arg_if_missing(infile_tok_first, infile_tok_last, 
arg_tok);
}
 }
+
+static int set_where(struct conf_info *item, const char *value)
+{
+   if (!strcasecmp(after, value)) {
+   item-where = WHERE_AFTER;
+   } else if (!strcasecmp(before, value)) {
+   item-where = WHERE_BEFORE;
+   } else
+   return 1;
+   return 0;
+}
+
+static int set_if_exist(struct conf_info *item, const char *value)
+{
+   if (!strcasecmp(addIfDifferent, value)) {
+   item-if_exist = EXIST_ADD_IF_DIFFERENT;
+   } else if (!strcasecmp(addIfDifferentNeighbor, value)) {
+   item-if_exist = EXIST_ADD_IF_DIFFERENT_NEIGHBOR;
+   } else if (!strcasecmp(add, value)) {
+   item-if_exist = EXIST_ADD;
+   } else if (!strcasecmp(overwrite, value)) {
+   item-if_exist = EXIST_OVERWRITE;
+   } else if (!strcasecmp(doNothing, value)) {
+   item-if_exist = EXIST_DO_NOTHING;
+   } else
+   return 1;
+   return 0;
+}
+
+static int set_if_missing(struct conf_info *item, const char *value)
+{
+   if (!strcasecmp(doNothing, value)) {
+   item-if_missing = MISSING_DO_NOTHING;
+   } else if (!strcasecmp(add, value)) {
+   item-if_missing = MISSING_ADD;
+   } else
+   return 1;
+   return 0;
+}
+
+enum trailer_info_type { TRAILER_VALUE, TRAILER_COMMAND, TRAILER_WHERE,
+TRAILER_IF_EXIST, TRAILER_IF_MISSING };
+
+static int set_name_and_type(const char *conf_key, const char *suffix,
+enum trailer_info_type type,
+char **pname, enum trailer_info_type *ptype)
+{
+   int ret = ends_with(conf_key, suffix);
+   if (ret) {
+   *pname = xstrndup(conf_key, strlen(conf_key) - strlen(suffix));
+   *ptype = type;
+   }
+   return ret;
+}
+
+static struct trailer_item *get_conf_item(char *name)
+{
+   struct trailer_item *item;
+   struct trailer_item *previous;
+
+   /* Look up item with same name */
+   for (previous = NULL, item = first_conf_item;
+item;
+previous = item, item = item-next)
+   {
+   if (!strcasecmp(item-conf-name, name))
+   return item;
+   }
+
+   /* Item does not already exists, create it */
+   item = xcalloc(sizeof(struct trailer_item), 1);
+   item-conf = xcalloc(sizeof(struct conf_info), 1);
+   item-conf-name = xstrdup(name);
+
+   if (!previous) {
+   first_conf_item = item;
+   } else {
+   previous-next = item;
+   item-previous = previous;
+   }
+
+   return item;
+}
+
+static int git_trailer_config(const char *conf_key, const char *value, void 
*cb)
+{
+   if (starts_with(conf_key, trailer.)) {
+   const char *orig_conf_key = conf_key;
+   struct trailer_item *item;
+   struct conf_info *conf;
+   char *name;
+   enum trailer_info_type type;
+
+   conf_key += 8;
+   if (!set_name_and_type(conf_key, .key, TRAILER_VALUE, name, 
type) 
+   !set_name_and_type(conf_key, .command, TRAILER_COMMAND, 
name, type) 
+   !set_name_and_type(conf_key, .where, TRAILER_WHERE, 
name, type) 
+   !set_name_and_type(conf_key, .ifexist, TRAILER_IF_EXIST, 
name, type) 
+   !set_name_and_type(conf_key, .ifmissing, 
TRAILER_IF_MISSING, name, type))
+   return 0;
+
+   item = get_conf_item(name);
+   conf = item-conf;
+
+   if (type == TRAILER_VALUE) {
+   if (conf-key)
+   warning(_(more than one %s), orig_conf_key);
+   conf-key = xstrdup(value);
+   } else if (type == TRAILER_COMMAND) {
+   if (conf-command)
+   warning(_(more than one %s), 

[PATCH v3 09/17] trailer: add tests for git interpret-trailers

2014-01-26 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 t/t7513-interpret-trailers.sh | 208 ++
 1 file changed, 208 insertions(+)
 create mode 100755 t/t7513-interpret-trailers.sh

diff --git a/t/t7513-interpret-trailers.sh b/t/t7513-interpret-trailers.sh
new file mode 100755
index 000..8be333c
--- /dev/null
+++ b/t/t7513-interpret-trailers.sh
@@ -0,0 +1,208 @@
+#!/bin/sh
+#
+# Copyright (c) 2013 Christian Couder
+#
+
+test_description='git interpret-trailers'
+
+. ./test-lib.sh
+
+cat basic_message 'EOF'
+subject
+
+body
+EOF
+
+cat complex_message_body 'EOF'
+my subject
+
+my body which is long
+and contains some special
+chars like : = ? !
+
+EOF
+
+# We want one trailing space at the end of each line.
+# Let's use sed to make sure that these spaces are not removed
+# by any automatic tool.
+sed -e 's/ Z$/ /' complex_message_trailers -\EOF
+Fixes: Z
+Acked-by: Z
+Reviewed-by: Z
+Signed-off-by: Z
+EOF
+
+test_expect_success 'without config' '
+   printf ack: Peff\nReviewed-by: \nAcked-by: Johan\n expected 
+   git interpret-trailers ack = Peff Reviewed-by Acked-by: Johan 
actual 
+   test_cmp expected actual
+'
+
+test_expect_success '--trim-empty without config' '
+   printf ack: Peff\nAcked-by: Johan\n expected 
+   git interpret-trailers --trim-empty ack = Peff Reviewed-by 
Acked-by: Johan sob: actual 
+   test_cmp expected actual
+'
+
+test_expect_success 'with config setup' '
+   git config trailer.ack.key Acked-by:  
+   printf Acked-by: Peff\n expected 
+   git interpret-trailers --trim-empty ack = Peff actual 
+   test_cmp expected actual 
+   git interpret-trailers --trim-empty Acked-by = Peff actual 
+   test_cmp expected actual 
+   git interpret-trailers --trim-empty Acked-by :Peff actual 
+   test_cmp expected actual
+'
+
+test_expect_success 'with config setup and = sign' '
+   git config trailer.ack.key Acked-by=  
+   printf Acked-by= Peff\n expected 
+   git interpret-trailers --trim-empty ack = Peff actual 
+   test_cmp expected actual 
+   git interpret-trailers --trim-empty Acked-by= Peff actual 
+   test_cmp expected actual 
+   git interpret-trailers --trim-empty Acked-by : Peff actual 
+   test_cmp expected actual
+'
+
+test_expect_success 'with config setup and # sign' '
+   git config trailer.bug.key Bug # 
+   printf Bug #42\n expected 
+   git interpret-trailers --trim-empty bug = 42 actual 
+   test_cmp expected actual
+'
+
+test_expect_success 'with commit basic message' '
+   git interpret-trailers --infile basic_message actual 
+   test_cmp basic_message actual
+'
+
+test_expect_success 'with commit complex message' '
+   cat complex_message_body complex_message_trailers complex_message 
+   cat complex_message_body expected 
+   printf Fixes: \nAcked-by= \nReviewed-by: \nSigned-off-by: \n 
expected 
+   git interpret-trailers --infile complex_message actual 
+   test_cmp expected actual
+'
+
+test_expect_success 'with commit complex message and args' '
+   cat complex_message_body expected 
+   printf Fixes: \nAcked-by= \nAcked-by= Peff\nReviewed-by: 
\nSigned-off-by: \nBug #42\n expected 
+   git interpret-trailers --infile complex_message ack: Peff bug: 42 
actual 
+   test_cmp expected actual
+'
+
+test_expect_success 'with commit complex message, args and --trim-empty' '
+   cat complex_message_body expected 
+   printf Acked-by= Peff\nBug #42\n expected 
+   git interpret-trailers --trim-empty --infile complex_message ack: 
Peff bug: 42 actual 
+   test_cmp expected actual
+'
+
+test_expect_success 'using where = before' '
+   git config trailer.bug.where before 
+   cat complex_message_body expected 
+   printf Bug #42\nFixes: \nAcked-by= \nAcked-by= Peff\nReviewed-by: 
\nSigned-off-by: \n expected 
+   git interpret-trailers --infile complex_message ack: Peff bug: 42 
actual 
+   test_cmp expected actual
+'
+
+test_expect_success 'using where = before for a token in the middle of 
infile' '
+   git config trailer.review.key Reviewed-by: 
+   git config trailer.review.where before 
+   cat complex_message_body expected 
+   printf Bug #42\nFixes: \nAcked-by= \nAcked-by= Peff\nReviewed-by: 
Johan\nReviewed-by: \nSigned-off-by: \n expected 
+   git interpret-trailers --infile complex_message ack: Peff bug: 42 
review: Johan actual 
+   test_cmp expected actual
+'
+
+test_expect_success 'using where = before and --trim-empty' '
+   cat complex_message_body expected 
+   printf Bug #46\nBug #42\nAcked-by= Peff\nReviewed-by: Johan\n 
expected 
+   git interpret-trailers --infile complex_message --trim-empty ack: 
Peff bug: 42 review: Johan Bug: 46  actual 
+   test_cmp expected actual
+'
+
+test_expect_success 'the default is ifExist = addIfDifferent' '
+   cat complex_message_body expected 
+   

[PATCH v3 15/17] trailer: set author and committer env variables

2014-01-26 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 trailer.c | 30 +-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/trailer.c b/trailer.c
index dc81a01..6c2a2b9 100644
--- a/trailer.c
+++ b/trailer.c
@@ -1,5 +1,6 @@
 #include cache.h
 #include run-command.h
+#include argv-array.h
 /*
  * Copyright (c) 2013 Christian Couder chrisc...@tuxfamily.org
  */
@@ -415,14 +416,40 @@ static int read_from_command(struct child_process *cp, 
struct strbuf *buf)
return 0;
 }
 
+static void setup_ac_env(struct argv_array *env, const char *ac_name, const 
char *ac_mail, const char *(*read)(int))
+{
+   if (!getenv(ac_name) || !getenv(ac_mail)) {
+   struct ident_split ident;
+   const char *namebuf, *mailbuf;
+   int namelen, maillen;
+   const char *ac_info = read(IDENT_NO_DATE);
+
+   if (split_ident_line(ident, ac_info, strlen(ac_info)))
+   return;
+
+   namelen = ident.name_end - ident.name_begin;
+   namebuf = ident.name_begin;
+
+   maillen = ident.mail_end - ident.mail_begin;
+   mailbuf = ident.mail_begin;
+
+   argv_array_pushf(env, %s=%.*s, ac_name, namelen, namebuf);
+   argv_array_pushf(env, %s=%.*s, ac_mail, maillen, mailbuf);
+   }
+}
+
 static const char *apply_command(const char *command, const char *arg)
 {
+   struct argv_array env = ARGV_ARRAY_INIT;
struct strbuf cmd = STRBUF_INIT;
struct strbuf buf = STRBUF_INIT;
struct child_process cp;
const char *argv[] = {NULL, NULL};
const char *result = ;
 
+   setup_ac_env(env, GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, 
git_author_info);
+   setup_ac_env(env, GIT_COMMITTER_NAME, GIT_COMMITTER_EMAIL, 
git_committer_info);
+
strbuf_addstr(cmd, command);
if (arg)
strbuf_replace(cmd, TRAILER_ARG_STRING, arg);
@@ -430,7 +457,7 @@ static const char *apply_command(const char *command, const 
char *arg)
argv[0] = cmd.buf;
memset(cp, 0, sizeof(cp));
cp.argv = argv;
-   cp.env = local_repo_env;
+   cp.env = env.argv;
cp.no_stdin = 1;
cp.out = -1;
cp.use_shell = 1;
@@ -441,6 +468,7 @@ static const char *apply_command(const char *command, const 
char *arg)
result = strbuf_detach(buf, NULL);
 
strbuf_release(cmd);
+   argv_array_clear(env);
return result;
 }
 
-- 
1.8.5.2.201.gacc5987


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


[PATCH v3 08/17] trailer: add interpret-trailers command

2014-01-26 Thread Christian Couder
This patch adds the git interpret-trailers command.
This command uses the previously added process_trailers()
function in trailer.c.

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 .gitignore   |  1 +
 Makefile |  1 +
 builtin.h|  1 +
 builtin/interpret-trailers.c | 36 
 git.c|  1 +
 trailer.h|  6 ++
 6 files changed, 46 insertions(+)
 create mode 100644 builtin/interpret-trailers.c
 create mode 100644 trailer.h

diff --git a/.gitignore b/.gitignore
index b5f9def..c870ada 100644
--- a/.gitignore
+++ b/.gitignore
@@ -74,6 +74,7 @@
 /git-index-pack
 /git-init
 /git-init-db
+/git-interpret-trailers
 /git-instaweb
 /git-log
 /git-ls-files
diff --git a/Makefile b/Makefile
index ec90feb..a91465e 100644
--- a/Makefile
+++ b/Makefile
@@ -935,6 +935,7 @@ BUILTIN_OBJS += builtin/hash-object.o
 BUILTIN_OBJS += builtin/help.o
 BUILTIN_OBJS += builtin/index-pack.o
 BUILTIN_OBJS += builtin/init-db.o
+BUILTIN_OBJS += builtin/interpret-trailers.o
 BUILTIN_OBJS += builtin/log.o
 BUILTIN_OBJS += builtin/ls-files.o
 BUILTIN_OBJS += builtin/ls-remote.o
diff --git a/builtin.h b/builtin.h
index d4afbfe..30f4c30 100644
--- a/builtin.h
+++ b/builtin.h
@@ -71,6 +71,7 @@ extern int cmd_hash_object(int argc, const char **argv, const 
char *prefix);
 extern int cmd_help(int argc, const char **argv, const char *prefix);
 extern int cmd_index_pack(int argc, const char **argv, const char *prefix);
 extern int cmd_init_db(int argc, const char **argv, const char *prefix);
+extern int cmd_interpret_trailers(int argc, const char **argv, const char 
*prefix);
 extern int cmd_log(int argc, const char **argv, const char *prefix);
 extern int cmd_log_reflog(int argc, const char **argv, const char *prefix);
 extern int cmd_ls_files(int argc, const char **argv, const char *prefix);
diff --git a/builtin/interpret-trailers.c b/builtin/interpret-trailers.c
new file mode 100644
index 000..f79bffa
--- /dev/null
+++ b/builtin/interpret-trailers.c
@@ -0,0 +1,36 @@
+/*
+ * Builtin git interpret-trailers
+ *
+ * Copyright (c) 2013 Christian Couder chrisc...@tuxfamily.org
+ *
+ */
+
+#include cache.h
+#include builtin.h
+#include parse-options.h
+#include strbuf.h
+#include trailer.h
+
+static const char * const git_interpret_trailers_usage[] = {
+   N_(git interpret-trailers [--trim-empty] [--infile=file] 
[token[=value]...]),
+   NULL
+};
+
+int cmd_interpret_trailers(int argc, const char **argv, const char *prefix)
+{
+   const char *infile = NULL;
+   int trim_empty = 0;
+
+   struct option options[] = {
+   OPT_BOOL(0, trim-empty, trim_empty, N_(trim empty 
trailers)),
+   OPT_FILENAME(0, infile, infile, N_(use message from file)),
+   OPT_END()
+   };
+
+   argc = parse_options(argc, argv, prefix, options,
+git_interpret_trailers_usage, 0);
+
+   process_trailers(infile, trim_empty, argc, argv);
+
+   return 0;
+}
diff --git a/git.c b/git.c
index 3799514..1420b58 100644
--- a/git.c
+++ b/git.c
@@ -383,6 +383,7 @@ static void handle_internal_command(int argc, const char 
**argv)
{ index-pack, cmd_index_pack, RUN_SETUP_GENTLY },
{ init, cmd_init_db },
{ init-db, cmd_init_db },
+   { interpret-trailers, cmd_interpret_trailers, RUN_SETUP },
{ log, cmd_log, RUN_SETUP },
{ ls-files, cmd_ls_files, RUN_SETUP },
{ ls-remote, cmd_ls_remote, RUN_SETUP_GENTLY },
diff --git a/trailer.h b/trailer.h
new file mode 100644
index 000..9db4459
--- /dev/null
+++ b/trailer.h
@@ -0,0 +1,6 @@
+#ifndef TRAILER_H
+#define TRAILER_H
+
+void process_trailers(const char *infile, int trim_empty, int argc, const char 
**argv);
+
+#endif /* TRAILER_H */
-- 
1.8.5.2.201.gacc5987


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


[PATCH v3 10/17] trailer: if no input file is passed, read from stdin

2014-01-26 Thread Christian Couder
It is simpler and more natural if the git interpret-trailers
is made a filter as its output already goes to sdtout.

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 builtin/interpret-trailers.c  |  2 +-
 t/t7513-interpret-trailers.sh |  7 +++
 trailer.c | 15 +--
 3 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/builtin/interpret-trailers.c b/builtin/interpret-trailers.c
index f79bffa..37237f7 100644
--- a/builtin/interpret-trailers.c
+++ b/builtin/interpret-trailers.c
@@ -23,7 +23,7 @@ int cmd_interpret_trailers(int argc, const char **argv, const 
char *prefix)
 
struct option options[] = {
OPT_BOOL(0, trim-empty, trim_empty, N_(trim empty 
trailers)),
-   OPT_FILENAME(0, infile, infile, N_(use message from file)),
+   OPT_FILENAME(0, infile, infile, N_(use message from file, 
instead of stdin)),
OPT_END()
};
 
diff --git a/t/t7513-interpret-trailers.sh b/t/t7513-interpret-trailers.sh
index 8be333c..f5ef81f 100755
--- a/t/t7513-interpret-trailers.sh
+++ b/t/t7513-interpret-trailers.sh
@@ -205,4 +205,11 @@ test_expect_success 'using ifMissing = doNothing' '
test_cmp expected actual
 '
 
+test_expect_success 'with input from stdin' '
+   cat complex_message_body expected 
+   printf Bug #42\nFixes: \nAcked-by= \nAcked-by= Junio\nAcked-by= 
Peff\nReviewed-by: \nSigned-off-by: \n expected 
+   git interpret-trailers review: fix=53 cc=Linus ack: Junio 
fix=22 bug: 42 ack: Peff  complex_message actual 
+   test_cmp expected actual
+'
+
 test_done
diff --git a/trailer.c b/trailer.c
index 2678b3e..d581371 100644
--- a/trailer.c
+++ b/trailer.c
@@ -465,8 +465,13 @@ static struct strbuf **read_input_file(const char *infile)
 {
struct strbuf sb = STRBUF_INIT;
 
-   if (strbuf_read_file(sb, infile, 0)  0)
-   die_errno(_(could not read input file '%s'), infile);
+   if (infile) {
+   if (strbuf_read_file(sb, infile, 0)  0)
+   die_errno(_(could not read input file '%s'), infile);
+   } else {
+   if (strbuf_read(sb, fileno(stdin), 0)  0)
+   die_errno(_(could not read from stdin));
+   }
 
return strbuf_split(sb, '\n');
 }
@@ -531,10 +536,8 @@ void process_trailers(const char *infile, int trim_empty, 
int argc, const char *
 
git_config(git_trailer_config, NULL);
 
-   /* Print the non trailer part of infile */
-   if (infile) {
-   process_input_file(infile, infile_tok_first, infile_tok_last);
-   }
+   /* Print the non trailer part of infile (or stdin if infile is NULL) */
+   process_input_file(infile, infile_tok_first, infile_tok_last);
 
arg_tok_first = process_command_line_args(argc, argv);
 
-- 
1.8.5.2.201.gacc5987


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


[PATCH v3 04/17] trailer: process command line trailer arguments

2014-01-26 Thread Christian Couder
This patch parses the trailer command line arguments
and put the result into an arg_tok doubly linked
list.

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 trailer.c | 77 +++
 1 file changed, 77 insertions(+)

diff --git a/trailer.c b/trailer.c
index e7d8244..89377f2 100644
--- a/trailer.c
+++ b/trailer.c
@@ -363,3 +363,80 @@ static int git_trailer_config(const char *conf_key, const 
char *value, void *cb)
}
return 0;
 }
+
+static void parse_trailer(struct strbuf *tok, struct strbuf *val, const char 
*trailer)
+{
+   char *end = strchr(trailer, '=');
+   if (!end)
+   end = strchr(trailer, ':');
+   if (end) {
+   strbuf_add(tok, trailer, end - trailer);
+   strbuf_trim(tok);
+   strbuf_addstr(val, end + 1);
+   strbuf_trim(val);
+   } else {
+   strbuf_addstr(tok, trailer);
+   strbuf_trim(tok);
+   }
+}
+
+static struct trailer_item *create_trailer_item(const char *string)
+{
+   struct strbuf tok = STRBUF_INIT;
+   struct strbuf val = STRBUF_INIT;
+   struct trailer_item *new;
+   struct trailer_item *item;
+   int tok_alnum_len;
+
+   parse_trailer(tok, val, string);
+
+   tok_alnum_len = alnum_len(tok.buf, tok.len);
+
+   /* Lookup if the token matches something in the config */
+   for (item = first_conf_item; item; item = item-next) {
+   if (!strncasecmp(tok.buf, item-conf-key, tok_alnum_len) ||
+   !strncasecmp(tok.buf, item-conf-name, tok_alnum_len)) {
+   new = xcalloc(sizeof(struct trailer_item), 1);
+   new-conf = item-conf;
+   new-token = xstrdup(item-conf-key);
+   new-value = strbuf_detach(val, NULL);
+   strbuf_release(tok);
+   return new;
+   }
+   }
+
+   new = xcalloc(sizeof(struct trailer_item), 1);
+   new-conf = xcalloc(sizeof(struct conf_info), 1);
+   new-token = strbuf_detach(tok, NULL);
+   new-value = strbuf_detach(val, NULL);
+
+   return new;
+}
+
+static void add_trailer_item(struct trailer_item **first,
+struct trailer_item **last,
+struct trailer_item *new)
+{
+   if (!*last) {
+   *first = new;
+   *last = new;
+   } else {
+   (*last)-next = new;
+   new-previous = *last;
+   *last = new;
+   }
+}
+
+static struct trailer_item *process_command_line_args(int argc, const char 
**argv)
+{
+   int i;
+   struct trailer_item *arg_tok_first = NULL;
+   struct trailer_item *arg_tok_last = NULL;
+
+   for (i = 0; i  argc; i++) {
+   struct trailer_item *new = create_trailer_item(argv[i]);
+   add_trailer_item(arg_tok_first, arg_tok_last, new);
+   }
+
+   return arg_tok_first;
+}
-- 
1.8.5.2.201.gacc5987


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


[PATCH v3 05/17] strbuf: add strbuf_isspace()

2014-01-26 Thread Christian Couder
This helper function checks if a strbuf
contains only space chars or not.

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 strbuf.c | 7 +++
 strbuf.h | 1 +
 2 files changed, 8 insertions(+)

diff --git a/strbuf.c b/strbuf.c
index 83caf4a..2124bb8 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -124,6 +124,13 @@ void strbuf_ltrim(struct strbuf *sb)
sb-buf[sb-len] = '\0';
 }
 
+int strbuf_isspace(struct strbuf *sb)
+{
+   char *b;
+   for (b = sb-buf; *b  isspace(*b); b++);
+   return !*b;
+}
+
 struct strbuf **strbuf_split_buf(const char *str, size_t slen,
 int terminator, int max)
 {
diff --git a/strbuf.h b/strbuf.h
index 73e80ce..02bff3a 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -42,6 +42,7 @@ static inline void strbuf_setlen(struct strbuf *sb, size_t 
len) {
 extern void strbuf_trim(struct strbuf *);
 extern void strbuf_rtrim(struct strbuf *);
 extern void strbuf_ltrim(struct strbuf *);
+extern int strbuf_isspace(struct strbuf *);
 extern int strbuf_cmp(const struct strbuf *, const struct strbuf *);
 
 /*
-- 
1.8.5.2.201.gacc5987


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


[PATCH v3 00/17] Add interpret-trailers builtin

2014-01-26 Thread Christian Couder
This patch series implements a new command:

git interpret-trailers

and an infrastructure to process trailers that can be reused,
for example in commit.c.

1) Rationale:

This command should help with RFC 822 style headers, called
trailers, that are found at the end of commit messages.

(Note that these headers do not follow and are not intended to
follow many rules that are in RFC 822. For example they do not
follow the line breaking rules, the encoding rules and probably
many other rules.)

For a long time, these trailers have become a de facto standard
way to add helpful information into commit messages.

Until now git commit has only supported the well known
Signed-off-by:  trailer, that is used by many projects like
the Linux kernel and Git.

It is better to implement features for these trailers first in a
new command rather than in builtin/commit.c, because this way the
prepare-commit-msg and commit-msg hooks can reuse this command.

2) Current state:

Currently the usage string of this command is:

git interpret-trailers [--trim-empty] [--infile=file] [token[=value]...]

The following features are implemented:

- the result is printed on stdout
- the [token[=value]...] arguments are interpreted
- a commit message passed using the --infile=file option is 
interpreted
- if --infile is not used, a commit message is read from stdin
- the trailer.token.key options in the config are interpreted
- the trailer.token.where options are interpreted
- the trailer.token.ifExist options are interpreted
- the trailer.token.ifMissing options are interpreted
- the trailer.token.command config works
- $ARG can be used in commands
- ditto for GIT_{AUTHOR,COMMITTER}_{NAME,EMAIL} env variables
- there are some tests
- (new) there is some documentation

The following features are planned but not yet implemented:
- add more tests related to commands
- add examples in documentation
- integration with git commit

Possible improvements:
- support GIT_COMMIT_PROTO env variable in commands

3) Changes since version 2:

* the declared after statement are fixed
* the style issues in for loops are fixed
* there is some documentation


Christian Couder (17):
  Add data structures and basic functions for commit trailers
  trailer: process trailers from file and arguments
  trailer: read and process config information
  trailer: process command line trailer arguments
  strbuf: add strbuf_isspace()
  trailer: parse trailers from input file
  trailer: put all the processing together and print
  trailer: add interpret-trailers command
  trailer: add tests for git interpret-trailers
  trailer: if no input file is passed, read from stdin
  trailer: add new_trailer_item() function
  strbuf: add strbuf_replace()
  trailer: execute command from 'trailer.name.command'
  trailer: add tests for trailer command
  trailer: set author and committer env variables
  trailer: add tests for commands using env variables
  Documentation: add documentation for 'git interpret-trailers'

 .gitignore   |   1 +
 Documentation/git-interpret-trailers.txt | 137 +++
 Makefile |   2 +
 builtin.h|   1 +
 builtin/interpret-trailers.c |  36 ++
 git.c|   1 +
 strbuf.c |  14 +
 strbuf.h |   4 +
 t/t7513-interpret-trailers.sh| 262 +
 trailer.c| 638 +++
 trailer.h|   6 +
 11 files changed, 1102 insertions(+)
 create mode 100644 Documentation/git-interpret-trailers.txt
 create mode 100644 builtin/interpret-trailers.c
 create mode 100755 t/t7513-interpret-trailers.sh
 create mode 100644 trailer.c
 create mode 100644 trailer.h

-- 
1.8.5.2.201.gacc5987

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


[PATCH v3 01/17] Add data structures and basic functions for commit trailers

2014-01-26 Thread Christian Couder
We will use a doubly linked list to store all information
about trailers and their configuration.

This way we can easily remove or add trailers to or from
trailer lists while traversing the lists in either direction.

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 Makefile  |  1 +
 trailer.c | 47 +++
 2 files changed, 48 insertions(+)
 create mode 100644 trailer.c

diff --git a/Makefile b/Makefile
index b4af1e2..ec90feb 100644
--- a/Makefile
+++ b/Makefile
@@ -871,6 +871,7 @@ LIB_OBJS += submodule.o
 LIB_OBJS += symlinks.o
 LIB_OBJS += tag.o
 LIB_OBJS += trace.o
+LIB_OBJS += trailer.o
 LIB_OBJS += transport.o
 LIB_OBJS += transport-helper.o
 LIB_OBJS += tree-diff.o
diff --git a/trailer.c b/trailer.c
new file mode 100644
index 000..d80d047
--- /dev/null
+++ b/trailer.c
@@ -0,0 +1,47 @@
+#include cache.h
+/*
+ * Copyright (c) 2013 Christian Couder chrisc...@tuxfamily.org
+ */
+
+enum action_where { WHERE_AFTER, WHERE_BEFORE };
+enum action_if_exist { EXIST_ADD_IF_DIFFERENT, EXIST_ADD_IF_DIFFERENT_NEIGHBOR,
+  EXIST_ADD, EXIST_OVERWRITE, EXIST_DO_NOTHING };
+enum action_if_missing { MISSING_ADD, MISSING_DO_NOTHING };
+
+struct conf_info {
+   char *name;
+   char *key;
+   char *command;
+   enum action_where where;
+   enum action_if_exist if_exist;
+   enum action_if_missing if_missing;
+};
+
+struct trailer_item {
+   struct trailer_item *previous;
+   struct trailer_item *next;
+   const char *token;
+   const char *value;
+   struct conf_info *conf;
+};
+
+static int same_token(struct trailer_item *a, struct trailer_item *b, int 
alnum_len)
+{
+   return !strncasecmp(a-token, b-token, alnum_len);
+}
+
+static int same_value(struct trailer_item *a, struct trailer_item *b)
+{
+   return !strcasecmp(a-value, b-value);
+}
+
+static int same_trailer(struct trailer_item *a, struct trailer_item *b, int 
alnum_len)
+{
+   return same_token(a, b, alnum_len)  same_value(a, b);
+}
+
+/* Get the length of buf from its beginning until its last alphanumeric 
character */
+static size_t alnum_len(const char *buf, size_t len) {
+   while (--len = 0  !isalnum(buf[len]));
+   return len + 1;
+}
-- 
1.8.5.2.201.gacc5987


--
To unsubscribe from this list: send the line 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 04/16] trailer: process command line trailer arguments

2014-01-26 Thread Christian Couder
 Junio C Hamano gits...@pobox.com writes:
 
 +static struct trailer_item *create_trailer_item(const char *string)
 +{
 +   struct strbuf tok = STRBUF_INIT;
 +   struct strbuf val = STRBUF_INIT;
 +   struct trailer_item *new;
 +
 +   parse_trailer(tok, val, string);
 +
 +   int tok_alnum_len = alnum_len(tok.buf, tok.len);

 decl-after-stmt.

 +
 +   /* Lookup if the token matches something in the config */
 +   struct trailer_item *item;
 
 ditto.
 
 +   for (item = first_conf_item; item; item = item-next)
 +   {
 
 Style.

The decl-after-stmt and style problems are fixed in the new v3 series
I just sent.

 I wonder if Cc list is being a bit too wide for this series, by the
 way.

I included only people who where part of the discussions at some
point. I guess that if they are not interested anymore they can ask to
be removed from Cc.

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


[PATCH v5 0/4] submodule: Local branch creation in module_clone

2014-01-26 Thread W. Trevor King
Changes since v4:

In git-submodule.sh:

* Explicitly set an empty $local_branch in cmd_add if $branch is empty
  [1].
* Restore die-early checking for invalid $update_module [2].  This
  check is now outside the load-from-config branch, ensuring we have a
  valid update_module, regardless of how it was set.

In Documentation/git-submodule.txt:

* Fix “but be” → “but can be” [3].
* Fix “checkout” → “--checkout” [4].
* New text on why you'd use --remote [5] (new commit #4).

In Documentation/git-submodule.txt and Documentation/gitmodules.txt:

* Use backticks (instead of single quotes) for command line options
  [6].

I also squashed the implementation, testing fixes, new tests, and
documentation for the new local_branch stuff (v4's #3, #4, #5, and #6)
into a single commit (v5's #3) [7].

[1]: http://article.gmane.org/gmane.comp.version-control.git/240524
[2]: http://article.gmane.org/gmane.comp.version-control.git/240522
[3]: http://article.gmane.org/gmane.comp.version-control.git/240543
[4]: http://article.gmane.org/gmane.comp.version-control.git/240531
[5]: http://article.gmane.org/gmane.comp.version-control.git/240529
[6]: http://article.gmane.org/gmane.comp.version-control.git/240536
[7]: http://article.gmane.org/gmane.comp.version-control.git/240530

W. Trevor King (4):
  submodule: Make 'checkout' update_module explicit
  submodule: Document module_clone arguments in comments
  submodule: Explicit local branch creation in module_clone
  Documentation: Describe 'submodule update --remote' use case

 Documentation/git-submodule.txt | 46 -
 Documentation/gitmodules.txt|  4 ++
 git-submodule.sh| 89 ++---
 t/t7406-submodule-update.sh | 39 +-
 4 files changed, 136 insertions(+), 42 deletions(-)

-- 
1.8.5.2.8.g0f6c0d1

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


[PATCH v5 1/4] submodule: Make 'checkout' update_module explicit

2014-01-26 Thread W. Trevor King
This avoids the current awkwardness of having either '' or 'checkout'
for checkout-mode updates, which makes testing for checkout-mode
updates (or non-checkout-mode updates) easier.

Signed-off-by: W. Trevor King wk...@tremily.us
---
 git-submodule.sh | 27 +++
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index 5247f78..5e8776c 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -803,17 +803,10 @@ cmd_update()
update_module=$update
else
update_module=$(git config submodule.$name.update)
-   case $update_module in
-   '')
-   ;; # Unset update mode
-   checkout | rebase | merge | none)
-   ;; # Known update modes
-   !*)
-   ;; # Custom update command
-   *)
-   die $(eval_gettext Invalid update mode 
'$update_module' for submodule '$name')
-   ;;
-   esac
+   if test -z $update_module
+   then
+   update_module=checkout
+   fi
fi
 
displaypath=$(relative_path $prefix$sm_path)
@@ -882,11 +875,16 @@ Maybe you want to use 'update --init'?)
case ;$cloned_modules; in
*;$name;*)
# then there is no local change to integrate
-   update_module= ;;
+   update_module=checkout ;;
esac
 
must_die_on_failure=
case $update_module in
+   checkout)
+   command=git checkout $subforce -q
+   die_msg=$(eval_gettext Unable to checkout 
'\$sha1' in submodule path '\$displaypath')
+   say_msg=$(eval_gettext Submodule path 
'\$displaypath': checked out '\$sha1')
+   ;;
rebase)
command=git rebase
die_msg=$(eval_gettext Unable to rebase 
'\$sha1' in submodule path '\$displaypath')
@@ -906,10 +904,7 @@ Maybe you want to use 'update --init'?)
must_die_on_failure=yes
;;
*)
-   command=git checkout $subforce -q
-   die_msg=$(eval_gettext Unable to checkout 
'\$sha1' in submodule path '\$displaypath')
-   say_msg=$(eval_gettext Submodule path 
'\$displaypath': checked out '\$sha1')
-   ;;
+   die $(eval_gettext Invalid update mode 
'$update_module' for submodule '$name')
esac
 
if (clear_local_git_env; cd $sm_path  $command 
$sha1)
-- 
1.8.5.2.8.g0f6c0d1

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


[PATCH v5 3/4] submodule: Explicit local branch creation in module_clone

2014-01-26 Thread W. Trevor King
The previous code only checked out branches in cmd_add.  This commit
moves the branch-checkout logic into module_clone, where it can be
shared by cmd_add and cmd_update.  I also update the initial checkout
command to use 'reset' to preserve branches setup during module_clone.

With this change, folks cloning submodules for the first time via:

  $ git submodule update ...

will get a local branch instead of a detached HEAD, unless they are
using the default checkout-mode updates.  This is a change from the
previous situation where cmd_update always used checkout-mode logic
(regardless of the requested update mode) for updates that triggered
an initial clone, which always resulted in a detached HEAD.

This commit does not change the logic for updates after the initial
clone, which will continue to create detached HEADs for checkout-mode
updates, and integrate remote work with the local HEAD (detached or
not) in other modes.

The motivation for the change is that developers doing local work
inside the submodule are likely to select a non-checkout-mode for
updates so their local work is integrated with upstream work.
Developers who are not doing local submodule work stick with
checkout-mode updates so any apparently local work is blown away
during updates.  For example, if upstream rolls back the remote branch
or gitlinked commit to an earlier version, the checkout-mode developer
wants their old submodule checkout to be rolled back as well, instead
of getting a no-op merge/rebase with the rolled-back reference.

By using the update mode to distinguish submodule developers from
black-box submodule consumers, we can setup local branches for the
developers who will want local branches, and stick with detached HEADs
for the developers that don't care.

Testing
===

In t7406, just-cloned checkouts now update to the gitlinked hash with
'reset', to preserve the local branch for situations where we're not
on a detached HEAD.

I also added explicit tests to t7406 for HEAD attachement after
cloning updates, showing that it depends on their update mode:

* Checkout-mode updates get detached HEADs
* Everyone else gets a local branch, matching the configured
  submodule.name.branch and defaulting to master.

The 'initial-setup' tag makes it easy to reset the superproject to a
known state, as several earlier tests commit to submodules and commit
the changed gitlinks to the superproject, but don't push the new
submodule commits to the upstream subprojects.  This makes it
impossible to checkout the current super master, because it references
submodule commits that don't exist in the upstream subprojects.  For a
specific example, see the tests that currently generate the
'two_new_submodule_commits' commits.

Documentation
=

I updated the docs to describe the 'submodule update' modes in detail.
The old documentation did not distinguish between cloning and
non-cloning updates and lacked clarity on which operations would lead
to detached HEADs, and which would not.  The new documentation
addresses these issues while updating the docs to reflect the changes
introduced by this commit's explicit local branch creation in
module_clone.

I also add '--checkout' to the usage summary and group the update-mode
options into a single set.

Signed-off-by: W. Trevor King wk...@tremily.us
---
 Documentation/git-submodule.txt | 36 ++---
 Documentation/gitmodules.txt|  4 +++
 git-submodule.sh| 58 +
 t/t7406-submodule-update.sh | 39 ++-
 4 files changed, 110 insertions(+), 27 deletions(-)

diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
index bfef8a0..2e1c7a2 100644
--- a/Documentation/git-submodule.txt
+++ b/Documentation/git-submodule.txt
@@ -15,8 +15,8 @@ SYNOPSIS
 'git submodule' [--quiet] init [--] [path...]
 'git submodule' [--quiet] deinit [-f|--force] [--] path...
 'git submodule' [--quiet] update [--init] [--remote] [-N|--no-fetch]
- [-f|--force] [--rebase] [--reference repository] [--depth 
depth]
- [--merge] [--recursive] [--] [path...]
+ [-f|--force] [--rebase|--merge|--checkout] [--reference 
repository]
+ [--depth depth] [--recursive] [--] [path...]
 'git submodule' [--quiet] summary [--cached|--files] [(-n|--summary-limit) n]
  [commit] [--] [path...]
 'git submodule' [--quiet] foreach [--recursive] command
@@ -155,13 +155,31 @@ it contains local modifications.
 
 update::
Update the registered submodules, i.e. clone missing submodules and
-   checkout the commit specified in the index of the containing repository.
-   This will make the submodules HEAD be detached unless `--rebase` or
-   `--merge` is specified or the key `submodule.$name.update` is set to
-   `rebase`, `merge` or `none`. `none` can be overridden by specifying
-   `--checkout`. Setting the key `submodule.$name.update` to 

[PATCH v5 4/4] Documentation: Describe 'submodule update --remote' use case

2014-01-26 Thread W. Trevor King
On Thu, Jan 16, 2014 at 12:21:04PM -0800, Junio C Hamano wrote [1]:
 I think copying some motivation from the log message of 06b1abb5
 (submodule update: add --remote for submodule's upstream changes,
 2012-12-19) would help the readers here.  A naïve expectation from a
 casual reader of the above would be The superproject's tree ought
 to point at the same commit as the tip of the branch used in the
 submodule (modulo mirroring delays and somesuch), if the repository
 of the superproject and submodules are maintained properly, which
 would lead to when would any sane person need to use --remote in
 the first place???.

There have been other interpretation issues with the --remote option
as well.  With this commit, I try to make it clear that there is no
implicit floating going on; --remote lets you explicitly integrate the
upstream branch in your current HEAD (just like running 'git pull' in
the submodule).  The only distinction with the current 'git pull' is
the config location/setting used for the upstream branch, which is
hopefully clear now.

With syncing between the out-of-tree submodule config and the in-tree
superproject .gitmodules [2], you wouldn't have to chose between (or
manually sync) easily distributable .gitmodules settings and native
submodule pull, but this patch is my take on the current situation.

[1]: http://article.gmane.org/gmane.comp.version-control.git/240529
[2]: http://article.gmane.org/gmane.comp.version-control.git/240336

Signed-off-by: W. Trevor King wk...@tremily.us
---
 Documentation/git-submodule.txt | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
index 2e1c7a2..21cb59a 100644
--- a/Documentation/git-submodule.txt
+++ b/Documentation/git-submodule.txt
@@ -299,6 +299,16 @@ In order to ensure a current tracking branch state, 
`update --remote`
 fetches the submodule's remote repository before calculating the
 SHA-1.  If you don't want to fetch, you should use `submodule update
 --remote --no-fetch`.
++
+Use this option to integrate changes from the upstream subproject with
+your submodule's current HEAD.  Alternatively, you can run `git pull`
+from the submodule, which is equivalent except for the remote branch
+name: `update --remote` uses the default upstream repository and
+`submodule.name.branch`, while `git pull` uses the submodule's
+`branch.name.merge`.  Prefer `submodule.name.branch` if you want
+to distribute the default upstream branch with the superproject and
+`branch.name.merge` if you want a more native feel while working in
+the submodule itself.
 
 -N::
 --no-fetch::
-- 
1.8.5.2.8.g0f6c0d1

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


[PATCH v5 2/4] submodule: Document module_clone arguments in comments

2014-01-26 Thread W. Trevor King
Signed-off-by: W. Trevor King wk...@tremily.us
---
 git-submodule.sh | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/git-submodule.sh b/git-submodule.sh
index 5e8776c..68dcbe1 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -241,6 +241,12 @@ module_name()
 #
 # Clone a submodule
 #
+# $1 = submodule path
+# $2 = submodule name
+# $3 = URL to clone
+# $4 = reference repository to reuse (empty for independent)
+# $5 = depth argument for shallow clones (empty for deep)
+#
 # Prior to calling, cmd_update checks that a possibly existing
 # path is not a git repository.
 # Likewise, cmd_add checks that path does not exist at all,
-- 
1.8.5.2.8.g0f6c0d1

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


git blame vs git log --follow performance

2014-01-26 Thread Joe Perches
Hi.

Is there something that can be done about improving
git log --follow -- file performance to be nearly
equivalent speed to git blame -- file ?

The overall cpu time taken for these 2 commands that
track individual file history can be quite different.

git log --follow -- file
and
git blame -- file

It seems that there can be a couple orders of magnitude
delta in the overall time taken.

For instance (using the Linus' linux kernel git):

$ time git log --follow -- drivers/firmware/google/Kconfig  /dev/null

real0m42.329s
user0m40.984s
sys 0m0.792s

$ time git blame -- drivers/firmware/google/Kconfig  /dev/null

real0m0.963s
user0m0.860s
sys 0m0.096s

This particular file has never been renamed.

Looking at the output on screen, there does seem to
be 25+ seconds of cpu time consumed after the initial
(last shown) commit that introduces this file.

Perhaps adding a whole-file rename option to the
git log history simplification mechanism could
help?

Thoughts?

--
To unsubscribe from this list: send the line 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] doc: remote author/documentation sections from more pages

2014-01-26 Thread Michael Haggerty
We decided at 48bb914e (doc: drop author/documentation sections from
most pages, 2011-03-11) to remove author and documentation
sections from our documentation.  Remove a few stragglers.

Signed-off-by: Michael Haggerty mhag...@alum.mit.edu
---
These deletions were assented to on the Git mailing list by the
persons whose names are thereby removed.  (I mention this fact without
implying that people mentioned in documentation hold a veto over their
names' removal.)

 Documentation/git-column.txt   | 4 
 Documentation/git-for-each-ref.txt | 8 
 Documentation/git-http-backend.txt | 7 ---
 Documentation/git-notes.txt| 9 -
 Documentation/git-remote-ext.txt   | 4 
 Documentation/git-remote-fd.txt| 3 ---
 6 files changed, 35 deletions(-)

diff --git a/Documentation/git-column.txt b/Documentation/git-column.txt
index 5d6f1cc..850449e 100644
--- a/Documentation/git-column.txt
+++ b/Documentation/git-column.txt
@@ -44,10 +44,6 @@ OPTIONS
The number of spaces between columns. One space by default.
 
 
-Author
---
-Written by Nguyen Thai Ngoc Duy pclo...@gmail.com
-
 GIT
 ---
 Part of the linkgit:git[1] suite
diff --git a/Documentation/git-for-each-ref.txt 
b/Documentation/git-for-each-ref.txt
index d639abe..4240875 100644
--- a/Documentation/git-for-each-ref.txt
+++ b/Documentation/git-for-each-ref.txt
@@ -219,14 +219,6 @@ eval=`git for-each-ref --shell --format=$fmt \
 eval $eval
 
 
-Author
---
-Written by Junio C Hamano gits...@pobox.com.
-
-Documentation
--
-Documentation by Junio C Hamano and the git-list git@vger.kernel.org.
-
 SEE ALSO
 
 linkgit:git-show-ref[1]
diff --git a/Documentation/git-http-backend.txt 
b/Documentation/git-http-backend.txt
index e3bcdb5..16706cf 100644
--- a/Documentation/git-http-backend.txt
+++ b/Documentation/git-http-backend.txt
@@ -263,13 +263,6 @@ identifying information of the remote user who performed 
the push.
 All CGI environment variables are available to each of the hooks
 invoked by the 'git-receive-pack'.
 
-Author
---
-Written by Shawn O. Pearce spea...@spearce.org.
-
-Documentation
---
-Documentation by Shawn O. Pearce spea...@spearce.org.
 
 GIT
 ---
diff --git a/Documentation/git-notes.txt b/Documentation/git-notes.txt
index 46ef046..ecf3fcf 100644
--- a/Documentation/git-notes.txt
+++ b/Documentation/git-notes.txt
@@ -376,15 +376,6 @@ If not set in the environment, the list of notes to copy 
depends
 on the `notes.rewrite.command` and `notes.rewriteRef` settings.
 
 
-Author
---
-Written by Johannes Schindelin johannes.schinde...@gmx.de and
-Johan Herland jo...@herland.net
-
-Documentation
--
-Documentation by Johannes Schindelin and Johan Herland
-
 GIT
 ---
 Part of the linkgit:git[7] suite
diff --git a/Documentation/git-remote-ext.txt b/Documentation/git-remote-ext.txt
index 8cfc748..e4d89a7 100644
--- a/Documentation/git-remote-ext.txt
+++ b/Documentation/git-remote-ext.txt
@@ -116,10 +116,6 @@ begins with `ext::`.  Examples:
determined by the helper using environment variables (see
above).
 
-Documentation
---
-Documentation by Ilari Liusvaara, Jonathan Nieder and the Git list
-git@vger.kernel.org
 
 GIT
 ---
diff --git a/Documentation/git-remote-fd.txt b/Documentation/git-remote-fd.txt
index 933c2ad..768b512 100644
--- a/Documentation/git-remote-fd.txt
+++ b/Documentation/git-remote-fd.txt
@@ -50,9 +50,6 @@ EXAMPLES
 `git push fd::7,8/bar master`::
Same as above.
 
-Documentation
---
-Documentation by Ilari Liusvaara and the Git list git@vger.kernel.org
 
 GIT
 ---
-- 
1.8.5.2

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


Re: [PATCH 2/2] setup: Don't dereference in-tree symlinks for absolute paths

2014-01-26 Thread Martin Erik Werner
On Sun, Jan 26, 2014 at 06:19:25PM +0100, Torsten Bögershausen wrote:
 On 2014-01-26 15.22, Martin Erik Werner wrote:
  The prefix_path_gently() function currently applies real_path to
  everything if given an absolute path, dereferencing symlinks both
  outside and inside the work tree. In order to manipulate symliks in the
  work tree using absolute paths, symlinks should only be dereferenced
  outside the work tree.
  
  Modify prefix_path_gently() to first normalize the path in order to
  make sure path levels are separated by '/', then use this separator to
  check the real path of each level of the path until it has found the
  length that corresponds to the work tree.
  
  For absolute paths, the function did not, nor does now do, any actual
  prefixing, hence we simply remove the path corresponding to the work
  tree and return the remaining in-tree part of the path.
  
  Fixes t0060-82.
  
  Signed-off-by: Martin Erik Werner martinerikwer...@gmail.com
  ---
   setup.c   | 54 
  ---
   t/t0060-path-utils.sh |  2 +-
   2 files changed, 35 insertions(+), 21 deletions(-)
  
  diff --git a/setup.c b/setup.c
  index 6c3f85f..bec587e 100644
  --- a/setup.c
  +++ b/setup.c
  @@ -22,11 +22,41 @@ char *prefix_path_gently(const char *prefix, int len,
  const char *orig = path;
  char *sanitized;
  if (is_absolute_path(orig)) {
  -   const char *temp = real_path(path);
  -   sanitized = xmalloc(len + strlen(temp) + 1);
  -   strcpy(sanitized, temp);
  +   char npath[strlen(path)];
 Is this portable ?
 This is variable-length array, isn't it ?
 Using xmalloc() may be better
Ah, right, that looks bad now that you mention it.
  if (remaining_prefix)
  *remaining_prefix = 0;
  +   if (normalize_path_copy_len(npath, path, remaining_prefix))
  +   return NULL;
  +   const char *work_tree = get_git_work_tree();
 declaration after statements should be avoided (not only here)
 
Indeed, I somehow guessed that declaration-after-statement was ok and
tried to keep them close to usage, bad guess, evidently.

I've rerolled the last v1 patch accordingly:
* Use xmalloc() when initializing char* from strlen()
* Separate and move declarations to beginning of scope
* Fix a strcpy that should've been a strcat (which would've nuked DOS
  prefixes, I think)

  [PATCH v2 2/2] setup: Don't dereference in-tree symlinks for absolute paths

 setup.c   | 64 +++
 t/t0060-path-utils.sh |  2 +-
 2 files changed, 45 insertions(+), 21 deletions(-)

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


[PATCH v2 2/2] setup: Don't dereference in-tree symlinks for absolute paths

2014-01-26 Thread Martin Erik Werner
The prefix_path_gently() function currently applies real_path to
everything if given an absolute path, dereferencing symlinks both
outside and inside the work tree. In order to manipulate symliks in the
work tree using absolute paths, symlinks should only be dereferenced
outside the work tree.

Modify prefix_path_gently() to first normalize the path in order to
make sure path levels are separated by '/', then use this separator to
check the real path of each level of the path until it has found the
length that corresponds to the work tree.

For absolute paths, the function did not, nor does now do, any actual
prefixing, hence we simply remove the path corresponding to the work
tree and return the remaining in-tree part of the path.

Fixes t0060-82.

Signed-off-by: Martin Erik Werner martinerikwer...@gmail.com
---
 setup.c   | 64 +++
 t/t0060-path-utils.sh |  2 +-
 2 files changed, 45 insertions(+), 21 deletions(-)

diff --git a/setup.c b/setup.c
index 5432a31..0789a96 100644
--- a/setup.c
+++ b/setup.c
@@ -22,11 +22,51 @@ char *prefix_path_gently(const char *prefix, int len,
const char *orig = path;
char *sanitized;
if (is_absolute_path(orig)) {
-   const char *temp = real_path(path);
-   sanitized = xmalloc(len + strlen(temp) + 1);
-   strcpy(sanitized, temp);
+   int i, match;
+   size_t wtpartlen;
+   char *npath, *wtpart;
+   struct string_list list = STRING_LIST_INIT_DUP;
+   const char *work_tree = get_git_work_tree();
+   if (!work_tree)
+   return NULL;
+   npath = xmalloc(strlen(path) + 1);
if (remaining_prefix)
*remaining_prefix = 0;
+   if (normalize_path_copy_len(npath, path, remaining_prefix)) {
+   free(npath);
+   return NULL;
+   }
+
+   string_list_split(list, npath, '/', -1);
+   wtpart = xmalloc(strlen(npath) + 1);
+   i = 0;
+   match = 0;
+   strcpy(wtpart, list.items[i++].string);
+   strcat(wtpart, /);
+   if (strcmp(real_path(wtpart), work_tree) == 0) {
+   match = 1;
+   } else {
+   while (i  list.nr) {
+   strcat(wtpart, list.items[i++].string);
+   if (strcmp(real_path(wtpart), work_tree) == 0) {
+   match = 1;
+   break;
+   }
+   strcat(wtpart, /);
+   }
+   }
+   string_list_clear(list, 0);
+   if (!match) {
+   free(npath);
+   free(wtpart);
+   return NULL;
+   }
+
+   wtpartlen = strlen(wtpart);
+   sanitized = xmalloc(strlen(npath) - wtpartlen);
+   strcpy(sanitized, npath + wtpartlen + 1);
+   free(npath);
+   free(wtpart);
} else {
sanitized = xmalloc(len + strlen(path) + 1);
if (len)
@@ -34,26 +74,10 @@ char *prefix_path_gently(const char *prefix, int len,
strcpy(sanitized + len, path);
if (remaining_prefix)
*remaining_prefix = len;
-   }
-   if (normalize_path_copy_len(sanitized, sanitized, remaining_prefix))
-   goto error_out;
-   if (is_absolute_path(orig)) {
-   size_t root_len, len, total;
-   const char *work_tree = get_git_work_tree();
-   if (!work_tree)
-   goto error_out;
-   len = strlen(work_tree);
-   root_len = offset_1st_component(work_tree);
-   total = strlen(sanitized) + 1;
-   if (strncmp(sanitized, work_tree, len) ||
-   (len  root_len  sanitized[len] != '\0'  sanitized[len] 
!= '/')) {
-   error_out:
+   if (normalize_path_copy_len(sanitized, sanitized, 
remaining_prefix)) {
free(sanitized);
return NULL;
}
-   if (sanitized[len] == '/')
-   len++;
-   memmove(sanitized, sanitized + len, total - len);
}
return sanitized;
 }
diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh
index 3a0677a..03a12ac 100755
--- a/t/t0060-path-utils.sh
+++ b/t/t0060-path-utils.sh
@@ -190,7 +190,7 @@ test_expect_success SYMLINKS 'real path works on symlinks' '
test $sym = $(test-path-utils real_path $dir2/syml)
 '
 
-test_expect_failure SYMLINKS 'prefix_path works with work tree symlinks' '
+test_expect_success SYMLINKS 'prefix_path works with work tree 

Re: [PATCH] doc: remote author/documentation sections from more pages

2014-01-26 Thread Eric Sunshine
On Sun, Jan 26, 2014 at 6:43 PM, Michael Haggerty mhag...@alum.mit.edu wrote:
 Subject: [PATCH] doc: remote author/documentation sections from more pages

s/remote/remove/

 We decided at 48bb914e (doc: drop author/documentation sections from
 most pages, 2011-03-11) to remove author and documentation
 sections from our documentation.  Remove a few stragglers.

 Signed-off-by: Michael Haggerty mhag...@alum.mit.edu
--
To unsubscribe from this list: send the line 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] doc: remote author/documentation sections from more pages

2014-01-26 Thread Jonathan Nieder
Michael Haggerty wrote:

 We decided at 48bb914e (doc: drop author/documentation sections from
 most pages, 2011-03-11) to remove author and documentation
 sections from our documentation.  Remove a few stragglers.

Thanks.

This puts two blank lines where there was previously one in some cases
in the source above the GIT (part of the git suite) section.  I
don't think that matters.

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


Re: [PATCH v2 2/2] setup: Don't dereference in-tree symlinks for absolute paths

2014-01-26 Thread Duy Nguyen
On Mon, Jan 27, 2014 at 7:07 AM, Martin Erik Werner
martinerikwer...@gmail.com wrote:
 diff --git a/setup.c b/setup.c
 index 5432a31..0789a96 100644
 --- a/setup.c
 +++ b/setup.c
 @@ -22,11 +22,51 @@ char *prefix_path_gently(const char *prefix, int len,
 const char *orig = path;
 char *sanitized;
 if (is_absolute_path(orig)) {
 -   const char *temp = real_path(path);
 -   sanitized = xmalloc(len + strlen(temp) + 1);
 -   strcpy(sanitized, temp);
 +   int i, match;
 +   size_t wtpartlen;
 +   char *npath, *wtpart;
 +   struct string_list list = STRING_LIST_INIT_DUP;
 +   const char *work_tree = get_git_work_tree();
 +   if (!work_tree)
 +   return NULL;
 +   npath = xmalloc(strlen(path) + 1);
 if (remaining_prefix)
 *remaining_prefix = 0;
 +   if (normalize_path_copy_len(npath, path, remaining_prefix)) {
 +   free(npath);
 +   return NULL;
 +   }
 +
 +   string_list_split(list, npath, '/', -1);
 +   wtpart = xmalloc(strlen(npath) + 1);
 +   i = 0;
 +   match = 0;

 +   strcpy(wtpart, list.items[i++].string);
 +   strcat(wtpart, /);
 +   if (strcmp(real_path(wtpart), work_tree) == 0) {
 +   match = 1;
 +   } else {

Could we remove this part and let the while loop handle the first path
component too? The only difference I see is if this code matches, we
have a trailing slash, while the while loop does not have a trailing
slash in wtpart.

 +   while (i  list.nr) {
 +   strcat(wtpart, list.items[i++].string);
 +   if (strcmp(real_path(wtpart), work_tree) == 
 0) {
 +   match = 1;
 +   break;
 +   }
 +   strcat(wtpart, /);
 +   }
 +   }
 +   string_list_clear(list, 0);
 +   if (!match) {
 +   free(npath);
 +   free(wtpart);
 +   return NULL;
 +   }
 +
 +   wtpartlen = strlen(wtpart);
 +   sanitized = xmalloc(strlen(npath) - wtpartlen);
 +   strcpy(sanitized, npath + wtpartlen + 1);

This + 1 is to ignore '/', isn't it? If so we should not do if match
is set 1 outside while loop.

 +   free(npath);
 +   free(wtpart);

All this new code looks long enough to be a separate function with a
meaningful name. And we could travese through each path component in
npath without wtpart (replacing '/' with '\0' to terminate the string
temporarily for real_path()). But it's up to you. Whichever way is
easier to read to you.

 } else {
 sanitized = xmalloc(len + strlen(path) + 1);
 if (len)
 @@ -34,26 +74,10 @@ char *prefix_path_gently(const char *prefix, int len,
 strcpy(sanitized + len, path);
 if (remaining_prefix)
 *remaining_prefix = len;
 -   }
 -   if (normalize_path_copy_len(sanitized, sanitized, remaining_prefix))
 -   goto error_out;
 -   if (is_absolute_path(orig)) {
 -   size_t root_len, len, total;
 -   const char *work_tree = get_git_work_tree();
 -   if (!work_tree)
 -   goto error_out;
 -   len = strlen(work_tree);
 -   root_len = offset_1st_component(work_tree);
 -   total = strlen(sanitized) + 1;
 -   if (strncmp(sanitized, work_tree, len) ||
 -   (len  root_len  sanitized[len] != '\0'  
 sanitized[len] != '/')) {
 -   error_out:
 +   if (normalize_path_copy_len(sanitized, sanitized, 
 remaining_prefix)) {
 free(sanitized);
 return NULL;
 }
 -   if (sanitized[len] == '/')
 -   len++;
 -   memmove(sanitized, sanitized + len, total - len);
 }
 return sanitized;
  }
-- 
Duy
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 17/17] Documentation: add documentation for 'git interpret-trailers'

2014-01-26 Thread Eric Sunshine
On Sun, Jan 26, 2014 at 12:00 PM, Christian Couder
chrisc...@tuxfamily.org wrote:
 Signed-off-by: Christian Couder chrisc...@tuxfamily.org
 ---
 diff --git a/Documentation/git-interpret-trailers.txt 
 b/Documentation/git-interpret-trailers.txt
 new file mode 100644
 index 000..f74843e
 --- /dev/null
 +++ b/Documentation/git-interpret-trailers.txt
 @@ -0,0 +1,137 @@
 +git-interpret-trailers(1)
 +=
 +
 +NAME
 +
 +git-interpret-trailers - help add stuctured information into commit messages
 +
 +SYNOPSIS
 +
 +[verse]
 +'git interpret-trailers' [--trim-empty] [--infile=file] [token[=value]...]

Would it be more consistent with existing documentation to format this as so?

  [--infile=file] [token[=value]]...

 +DESCRIPTION
 +---
 +Help add RFC 822 like headers, called 'trailers', at the end of the

s/822 like/822-like/

Was the suggestion, early in the discussion, to use footer rather
than trailer dismissed?

 +otherwise free-form part of a commit message.
 +
 +Unless `--infile=file` is used, this command is a filter. It reads the
 +standard input for a commit message and apply the `token` arguments,

s/apply/applies/

 +if any, to this message. The resulting message is emited on the
 +standard output.
 +
 +Some configuration variables control the way the `token` arguments are
 +applied to the message and the way any existing trailer in the message
 +is changed. They also make it possible to automatically add some
 +trailers.
 +
 +By default, a 'token=value' or 'token:value' argument will be added
 +only if no trailer with the same (token, value) pair is already in the
 +message. The 'token' and 'value' parts will be trimmed to remove
 +starting and trailing white spaces, and the resulting trimmed 'token'

Other git documentation uniformly spells it as whitespace rather
than white spaces.

 +and 'value' will appear in the message like this:
 +
 +
 +token: value
 +
 +
 +By default, if there are already trailers with the same 'token' the
 +trailer will appear just after the last trailer with the same

It might be a bit clearer to say the _new_ trailer will appear

 +'token'. Otherwise it will appear at the end of the message.
 +
 +Note that 'trailers' do not follow and are not intended to follow many
 +rules that are in RFC 822. For example they do not follow the line
 +breaking rules, the encoding rules and probably many other rules.
 +
 +Trailers have become a de facto standard way to add helpful structured
 +information into commit messages. For example the well known
 +Signed-off-by:  trailer is used by many projects like the Linux
 +kernel and Git.

This justification paragraph might make more sense near or at the
very the top of the Description section.

 +OPTIONS
 +---
 +--trim-empty::
 +   If the 'value' part of any trailer contains onlywhite spaces,

s/onlywhite spaces/only whitespace/

 +   the whole trailer will be removed from the resulting message.
 +
 +infile=file::
 +   Read the commit message from `file` instead of the standard
 +   input.
 +
 +CONFIGURATION VARIABLES
 +---
 +
 +trailer.token.key::
 +   This 'key' will be used instead of 'token' in the
 +   trailer. After some alphanumeric characters, it can contain
 +   some non alphanumeric characters like ':', '=' or '#' that will
 +   be used instead of ':' to separate the token from the value in
 +   the trailer, though the default ':' is more standard.
 +
 +trailer.token.where::
 +   This can be either `after`, which is the default, or
 +   `before`. If it is `before`, then a trailer with the specified
 +   token, will appear before, instead of after, other trailers
 +   with the same token, or otherwise at the beginning, instead of
 +   at the end, of all the trailers.
 +
 +trailer.token.ifexist::
 +   This option makes it possible to chose what action will be

s/chose/choose/

 +   performed when there is already at least one trailer with the
 +   same token in the message.
 ++
 +The valid values for this option are: `addIfDifferent` (this is the
 +default), `addIfDifferentNeighbor`, `add`, `overwrite` or `doNothing`.
 ++
 +With `addIfDifferent`, a new trailer will be added only if no trailer
 +with the same (token, value) pair is already in the message.
 ++
 +With `addIfDifferentNeighbor`, a new trailer will be added only if no
 +trailer with the same (token, value) pair is above or below the line
 +where the new trailer will be added.
 ++
 +With `add`, a new trailer will be added, even if some trailers with
 +the same (token, value) pair are already in the message.
 ++
 +With `overwrite`, the new trailer will overwrite an existing trailer
 +with the same token.
 ++
 +With `doNothing`, nothing will be done, that is no new trailer will be
 +added if there is already one with the same token in the 

Re: [PATCH v5 1/4] submodule: Make 'checkout' update_module explicit

2014-01-26 Thread Eric Sunshine
On Sun, Jan 26, 2014 at 3:45 PM, W. Trevor King wk...@tremily.us wrote:
 This avoids the current awkwardness of having either '' or 'checkout'
 for checkout-mode updates, which makes testing for checkout-mode
 updates (or non-checkout-mode updates) easier.

 Signed-off-by: W. Trevor King wk...@tremily.us
 ---
  git-submodule.sh | 27 +++
  1 file changed, 11 insertions(+), 16 deletions(-)

 diff --git a/git-submodule.sh b/git-submodule.sh
 index 5247f78..5e8776c 100755
 --- a/git-submodule.sh
 +++ b/git-submodule.sh
 @@ -803,17 +803,10 @@ cmd_update()
 update_module=$update
 else
 update_module=$(git config submodule.$name.update)
 -   case $update_module in
 -   '')
 -   ;; # Unset update mode
 -   checkout | rebase | merge | none)
 -   ;; # Known update modes
 -   !*)
 -   ;; # Custom update command
 -   *)
 -   die $(eval_gettext Invalid update mode 
 '$update_module' for submodule '$name')
 -   ;;
 -   esac
 +   if test -z $update_module
 +   then
 +   update_module=checkout

Here, you (unnecessarily) quote 'checkout'...

 +   fi
 fi

 displaypath=$(relative_path $prefix$sm_path)
 @@ -882,11 +875,16 @@ Maybe you want to use 'update --init'?)
 case ;$cloned_modules; in
 *;$name;*)
 # then there is no local change to integrate
 -   update_module= ;;
 +   update_module=checkout ;;

But here you use bare (unquoted) 'checkout'. Bare is probably more idiomatic.

 esac

 must_die_on_failure=
 case $update_module in
 +   checkout)
 +   command=git checkout $subforce -q
 +   die_msg=$(eval_gettext Unable to checkout 
 '\$sha1' in submodule path '\$displaypath')
 +   say_msg=$(eval_gettext Submodule path 
 '\$displaypath': checked out '\$sha1')
 +   ;;
 rebase)
 command=git rebase
 die_msg=$(eval_gettext Unable to rebase 
 '\$sha1' in submodule path '\$displaypath')
 @@ -906,10 +904,7 @@ Maybe you want to use 'update --init'?)
 must_die_on_failure=yes
 ;;
 *)
 -   command=git checkout $subforce -q
 -   die_msg=$(eval_gettext Unable to checkout 
 '\$sha1' in submodule path '\$displaypath')
 -   say_msg=$(eval_gettext Submodule path 
 '\$displaypath': checked out '\$sha1')
 -   ;;
 +   die $(eval_gettext Invalid update mode 
 '$update_module' for submodule '$name')
 esac

 if (clear_local_git_env; cd $sm_path  $command 
 $sha1)
 --
 1.8.5.2.8.g0f6c0d1
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: git blame vs git log --follow performance

2014-01-26 Thread Duy Nguyen
On Mon, Jan 27, 2014 at 4:10 AM, Joe Perches j...@perches.com wrote:
 For instance (using the Linus' linux kernel git):

 $ time git log --follow -- drivers/firmware/google/Kconfig  /dev/null

 real0m42.329s
 user0m40.984s
 sys 0m0.792s

 $ time git blame -- drivers/firmware/google/Kconfig  /dev/null

 real0m0.963s
 user0m0.860s
 sys 0m0.096s


It's not fair to compare blame and log. If you compare, compare it to
non follow version

$ time git log --follow -- drivers/firmware/google/Kconfig  /dev/null

real0m35.552s
user0m35.120s
sys 0m0.383s

$ time git log -- drivers/firmware/google/Kconfig  /dev/null

real0m4.366s
user0m4.215s
sys 0m0.144s

Although because we need to detect rename, we can't really filter to
one path. So the base line is more like

$ time git log  /dev/null

real0m29.338s
user0m28.485s
sys 0m0.813s

with rename detection taking some more time.

 Perhaps adding a whole-file rename option to the
 git log history simplification mechanism could
 help?

 Thoughts?

I tested a version with rename detection logic removed. It did not
change the timing significantly. To improve --follow I think we need
to do something about path filtering.
-- 
Duy
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] doc: remote author/documentation sections from more pages

2014-01-26 Thread Michael Haggerty
On 01/27/2014 01:15 AM, Eric Sunshine wrote:
 On Sun, Jan 26, 2014 at 6:43 PM, Michael Haggerty mhag...@alum.mit.edu 
 wrote:
 Subject: [PATCH] doc: remote author/documentation sections from more pages
 
 s/remote/remove/

Gaah!  Git is a virus that invades your muscle memory and prevents you
from typing words that are similar to git subcommands.

Thanks for noticing.

Michael

-- 
Michael Haggerty
mhag...@alum.mit.edu
http://softwareswirl.blogspot.com/
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 1/4] submodule: Make 'checkout' update_module explicit

2014-01-26 Thread W. Trevor King
On Sun, Jan 26, 2014 at 08:32:04PM -0500, Eric Sunshine wrote:
 On Sun, Jan 26, 2014 at 3:45 PM, W. Trevor King wk...@tremily.us wrote:
  +   update_module=checkout
 
 Here, you (unnecessarily) quote 'checkout'...
 
  -   update_module= ;;
  +   update_module=checkout ;;
 
 But here you use bare (unquoted) 'checkout'. Bare is probably more
 idiomatic.

Whatever you want ;).  Queued for v6.

Cheers,
Trevor

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy


signature.asc
Description: OpenPGP digital signature


Re: git blame vs git log --follow performance

2014-01-26 Thread Joe Perches
On Mon, 2014-01-27 at 08:33 +0700, Duy Nguyen wrote:
 On Mon, Jan 27, 2014 at 4:10 AM, Joe Perches j...@perches.com wrote:
  For instance (using the Linus' linux kernel git):
 
  $ time git log --follow -- drivers/firmware/google/Kconfig  /dev/null
 
  real0m42.329s
  user0m40.984s
  sys 0m0.792s
 
  $ time git blame -- drivers/firmware/google/Kconfig  /dev/null
 
  real0m0.963s
  user0m0.860s
  sys 0m0.096s
 
 
 It's not fair to compare blame and log. If you compare, compare it to
 non follow version

Perhaps not, but git blame does follow renames.

$ git blame --help
[]
The origin of lines is automatically followed across
whole-file renames (currently there is no option to
turn the rename-following off). To follow lines moved
from one file to another, or to follow lines that were
copied and pasted from another file, etc., see the -C
and -M options.

 I tested a version with rename detection logic removed. It did not
 change the timing significantly. To improve --follow I think we need
 to do something about path filtering.

Perhaps the log history could stop being read when
a commit is found that creates the file without
another file being deleted in the same commit.


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


Re: git blame vs git log --follow performance

2014-01-26 Thread Duy Nguyen
On Mon, Jan 27, 2014 at 4:10 AM, Joe Perches j...@perches.com wrote:
 Is there something that can be done about improving
 git log --follow -- file performance to be nearly
 equivalent speed to git blame -- file ?

Not strictly about --follow, but there is room for improvement for
diff'ing in log in general. Right now we do diff HEAD HEAD~1, diff
HEAD~1 HEAD~2 and so on (--follow needs diff to detect rename). At
each step we load new tree objects and reparse. Notice after diff
HEAD HEAD~1 we may have HEAD~1 and its subtrees read and parsed
(not entirely). We could reuse that diff HEAD~1 HEAD~2.

On git.git, git log --raw takes 10s and it seems tree object reading
is about 2s.In ideal case we might be able to cut that to 1s. The tree
parsing code (update_tree_entry) takes about 5s. We might be able to
cut that in half, I'm not entirely sure. But there could be a lot of
work in caching HEAD~1 and the overhead may turn out too high for
any gain.
-- 
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


How to get notified of new releases?

2014-01-26 Thread Robert Dailey
Are there any dedicated mailing lists for git releases, or RSS feeds?
I am on Windows so I'd specifically be interested in notifications
when new releases or preview binaries are released on the Windows
platform. I'm constantly checking the website currently.
--
To unsubscribe from this list: send the line 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] l10n: de.po: translate 27 new messages

2014-01-26 Thread Ralf Thielow
Translate 27 new messages came from git.pot update in
df49095 (l10n: git.pot: v1.9 round 1 (27 new, 11 removed).

Signed-off-by: Ralf Thielow ralf.thie...@gmail.com
---

2014-01-24 Jiang Xin worldhello@gmail.com:

 Inconsistent ending colons, some have and some not.


Oops. Thanks! Here is v2.

 po/de.po | 90 
 1 file changed, 45 insertions(+), 45 deletions(-)

diff --git a/po/de.po b/po/de.po
index 9c03238..b824f45 100644
--- a/po/de.po
+++ b/po/de.po
@@ -442,9 +442,9 @@ msgstr[0] vor %lu Jahr
 msgstr[1] vor %lu Jahren
 
 #: diffcore-order.c:24
-#, fuzzy, c-format
+#, c-format
 msgid failed to read orderfile '%s'
-msgstr Fehler beim Lesen des Objektes '%s'.
+msgstr Fehler beim Lesen der Reihenfolgedatei '%s'.
 
 #: diff.c:113
 #, c-format
@@ -975,21 +975,23 @@ msgid 
 There is nothing to exclude from by :(exclude) patterns.\n
 Perhaps you forgot to add either ':/' or '.' ?
 msgstr 
+Es gibt nichts, was durch :(exclude) Muster ausgeschlossen wird.\n
+Vielleicht haben Sie vergessen entweder ':/' oder '.' hinzuzufügen?
 
 #: remote.c:753
-#, fuzzy, c-format
+#, c-format
 msgid Cannot fetch both %s and %s to %s
-msgstr Kann keine Commit-Beschreibung für %s bekommen
+msgstr Kann 'fetch' nicht für %s und %s nach %s ausführen.
 
 #: remote.c:757
 #, c-format
 msgid %s usually tracks %s, not %s
-msgstr 
+msgstr %s folgt üblicherweise %s, nicht %s
 
 #: remote.c:761
 #, c-format
 msgid %s tracks both %s and %s
-msgstr 
+msgstr %s folgt %s und %s
 
 #.
 #. * This last possibility doesn't occur because
@@ -997,9 +999,8 @@ msgstr 
 #. * the end of the list.
 #.
 #: remote.c:769
-#, fuzzy
 msgid Internal error
-msgstr interner Fehler
+msgstr Interner Fehler
 
 #: remote.c:1871
 #, c-format
@@ -1575,33 +1576,28 @@ msgid both modified:
 msgstr von beiden geändert:
 
 #: wt-status.c:275
-#, fuzzy
 msgid new file
-msgstr neue Datei:   %s
+msgstr neue Datei
 
 #: wt-status.c:277
 msgid copied
-msgstr 
+msgstr kopiert
 
 #: wt-status.c:279
-#, fuzzy
 msgid deleted
 msgstr gelöscht
 
 #: wt-status.c:285
-#, fuzzy
 msgid typechange
-msgstr Typänderung: %s
+msgstr Typänderung
 
 #: wt-status.c:287
-#, fuzzy
 msgid unknown
-msgstr unbekannt:%s
+msgstr unbekannt
 
 #: wt-status.c:289
-#, fuzzy
 msgid unmerged
-msgstr zusammenführen
+msgstr nicht zusammengeführt
 
 #: wt-status.c:336
 msgid new commits, 
@@ -1633,6 +1629,8 @@ msgid 
 Do not touch the line above.\n
 Everything below will be removed.
 msgstr 
+Ändern Sie nicht die Zeile oberhalb.\n
+Alles unterhalb wird entfernt.
 
 #: wt-status.c:899
 msgid You have unmerged paths.
@@ -3991,14 +3989,14 @@ msgid reference repository '%s' is not a local 
repository.
 msgstr Referenziertes Repository '%s' ist kein lokales Repository.
 
 #: builtin/clone.c:256
-#, fuzzy, c-format
+#, c-format
 msgid reference repository '%s' is shallow
-msgstr Referenziertes Repository '%s' ist kein lokales Repository.
+msgstr Referenziertes Repository '%s' ist unvollständig (shallow).
 
 #: builtin/clone.c:259
-#, fuzzy, c-format
+#, c-format
 msgid reference repository '%s' is grafted
-msgstr referenziert Repository
+msgstr Referenziertes Repository '%s' ist gesondert eingehängt (graft).
 
 #: builtin/clone.c:321
 #, c-format
@@ -4099,16 +4097,16 @@ msgstr 
 
 #: builtin/clone.c:805
 msgid source repository is shallow, ignoring --local
-msgstr 
+msgstr Quelle ist ein unvollständiges Repository (shallow), ignoriere --local
 
 #: builtin/clone.c:810
 msgid --local is ignored
 msgstr --local wird ignoriert
 
 #: builtin/clone.c:814 builtin/fetch.c:1119
-#, fuzzy, c-format
+#, c-format
 msgid depth %s is not a positive number
-msgstr Objekt %s ist kein Blob
+msgstr Tiefe %s ist keine positive Zahl
 
 #: builtin/clone.c:824
 #, c-format
@@ -5215,9 +5213,8 @@ msgid default mode for recursion
 msgstr Standard-Modus für Rekursion
 
 #: builtin/fetch.c:109
-#, fuzzy
 msgid accept refs that update .git/shallow
-msgstr Konnte aktualisierte .gitmodules-Datei nicht lesen
+msgstr akzeptiert Referenzen die .git/shallow aktualisieren
 
 #: builtin/fetch.c:347
 msgid Couldn't find remote ref HEAD
@@ -5287,7 +5284,8 @@ msgstr %s hat nicht alle erforderlichen Objekte 
gesendet\n
 #: builtin/fetch.c:579
 #, c-format
 msgid reject %s because shallow roots are not allowed to be updated
-msgstr 
+msgstr %s wurde zurückgewiesen, da Ursprungs-Commits von unvollständigen\n
+Repositories (shallow) nicht aktualisiert werden dürfen.
 
 #: builtin/fetch.c:667 builtin/fetch.c:750
 #, c-format
@@ -7181,9 +7179,8 @@ msgid git merge-base --is-ancestor commit commit
 msgstr git merge-base --is-ancestor Commit Commit
 
 #: builtin/merge-base.c:33
-#, fuzzy
 msgid git merge-base --fork-point ref [commit]
-msgstr git merge-base --is-ancestor Commit Commit
+msgstr git merge-base --fork-point Referenz [Commit]
 
 #: builtin/merge-base.c:214
 msgid output all common ancestors
@@ -7203,7 +7200,7 @@ msgstr ist der Erste ein Vorgänger-Commit von dem 
Anderen?
 
 #: