Re: [RFC PATCH v2 2/2] headers: include dependent headers

2014-09-07 Thread René Scharfe
Am 07.09.2014 um 02:30 schrieb David Aguilar:
 Add dependent headers so that including a header does not
 require including additional headers.
 
 This makes it so that gcc -c $header succeeds for each header.
 
 Signed-off-by: David Aguilar dav...@gmail.com
 ---
 Addresses René's note to not include strbuf.h when cache.h is already
 included.

Perhaps squash this in in order to catch two more cases and also
avoid including git-compat-util.h if we already have cache.h:

diff --git a/builtin.h b/builtin.h
index df40fce..0419af3 100644
--- a/builtin.h
+++ b/builtin.h
@@ -1,7 +1,6 @@
 #ifndef BUILTIN_H
 #define BUILTIN_H
 
-#include git-compat-util.h
 #include cache.h
 #include commit.h
 
diff --git a/commit.h b/commit.h
index 1fe0731..dddc876 100644
--- a/commit.h
+++ b/commit.h
@@ -3,7 +3,6 @@
 
 #include object.h
 #include tree.h
-#include strbuf.h
 #include decorate.h
 #include gpg-interface.h
 #include string-list.h
diff --git a/dir.h b/dir.h
index 727160e..6b1 100644
--- a/dir.h
+++ b/dir.h
@@ -3,7 +3,6 @@
 
 /* See Documentation/technical/api-directory-listing.txt */
 
-#include strbuf.h
 #include pathspec.h
 #include cache.h
 
diff --git a/khash.h b/khash.h
index 89f9579..fc8b1bf 100644
--- a/khash.h
+++ b/khash.h
@@ -26,7 +26,6 @@
 #ifndef __AC_KHASH_H
 #define __AC_KHASH_H
 
-#include git-compat-util.h
 #include cache.h
 
 #define AC_VERSION_KHASH_H 0.2.8

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


[PATCH 1/2] strbuf: export strbuf_addchars()

2014-09-07 Thread René Scharfe
Move strbuf_addchars() to strbuf.c, where it belongs, and make it
available for other callers.

Signed-off-by: Rene Scharfe l@web.de
---
 Documentation/technical/api-strbuf.txt | 4 
 strbuf.c   | 7 +++
 strbuf.h   | 1 +
 utf8.c | 7 ---
 4 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/Documentation/technical/api-strbuf.txt 
b/Documentation/technical/api-strbuf.txt
index 430302c..cca6543 100644
--- a/Documentation/technical/api-strbuf.txt
+++ b/Documentation/technical/api-strbuf.txt
@@ -160,6 +160,10 @@ then they will free() it.
 
Add a single character to the buffer.
 
+`strbuf_addchars`::
+
+   Add a character the specified number of times to the buffer.
+
 `strbuf_insert`::
 
Insert data to the given position of the buffer. The remaining contents
diff --git a/strbuf.c b/strbuf.c
index 4d31443..0346e74 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -204,6 +204,13 @@ void strbuf_adddup(struct strbuf *sb, size_t pos, size_t 
len)
strbuf_setlen(sb, sb-len + len);
 }
 
+void strbuf_addchars(struct strbuf *sb, int c, size_t n)
+{
+   strbuf_grow(sb, n);
+   memset(sb-buf + sb-len, c, n);
+   strbuf_setlen(sb, sb-len + n);
+}
+
 void strbuf_addf(struct strbuf *sb, const char *fmt, ...)
 {
va_list ap;
diff --git a/strbuf.h b/strbuf.h
index 7bdc1da..652b6c4 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -138,6 +138,7 @@ static inline void strbuf_addbuf(struct strbuf *sb, const 
struct strbuf *sb2)
strbuf_add(sb, sb2-buf, sb2-len);
 }
 extern void strbuf_adddup(struct strbuf *sb, size_t pos, size_t len);
+extern void strbuf_addchars(struct strbuf *sb, int c, size_t n);
 
 typedef size_t (*expand_fn_t) (struct strbuf *sb, const char *placeholder, 
void *context);
 extern void strbuf_expand(struct strbuf *sb, const char *format, expand_fn_t 
fn, void *context);
diff --git a/utf8.c b/utf8.c
index b30790d..6d4d04a 100644
--- a/utf8.c
+++ b/utf8.c
@@ -239,13 +239,6 @@ int is_utf8(const char *text)
return 1;
 }
 
-static void strbuf_addchars(struct strbuf *sb, int c, size_t n)
-{
-   strbuf_grow(sb, n);
-   memset(sb-buf + sb-len, c, n);
-   strbuf_setlen(sb, sb-len + n);
-}
-
 static void strbuf_add_indented_text(struct strbuf *buf, const char *text,
 int indent, int indent2)
 {
-- 
2.1.0

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


[PATCH 2/2] strbuf: use strbuf_addchars() for adding a char multiple times

2014-09-07 Thread René Scharfe
Signed-off-by: Rene Scharfe l@web.de
---
 graph.c   |  5 ++---
 merge-recursive.c |  4 +---
 pretty.c  | 10 +++---
 3 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/graph.c b/graph.c
index 6404331..dfb99f6 100644
--- a/graph.c
+++ b/graph.c
@@ -1145,7 +1145,7 @@ int graph_next_line(struct git_graph *graph, struct 
strbuf *sb)
 
 static void graph_padding_line(struct git_graph *graph, struct strbuf *sb)
 {
-   int i, j;
+   int i;
 
if (graph-state != GRAPH_COMMIT) {
graph_next_line(graph, sb);
@@ -1169,8 +1169,7 @@ static void graph_padding_line(struct git_graph *graph, 
struct strbuf *sb)
strbuf_addch(sb, ' ');
else {
int num_spaces = ((graph-num_parents - 2) * 2);
-   for (j = 0; j  num_spaces; j++)
-   strbuf_addch(sb, ' ');
+   strbuf_addchars(sb, ' ', num_spaces);
}
} else {
strbuf_write_column(sb, col, '|');
diff --git a/merge-recursive.c b/merge-recursive.c
index 1d332b8..dd657e6 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -163,9 +163,7 @@ static void output(struct merge_options *o, int v, const 
char *fmt, ...)
if (!show(o, v))
return;
 
-   strbuf_grow(o-obuf, o-call_depth * 2 + 2);
-   memset(o-obuf.buf + o-obuf.len, ' ', o-call_depth * 2);
-   strbuf_setlen(o-obuf, o-obuf.len + o-call_depth * 2);
+   strbuf_addchars(o-obuf, ' ', o-call_depth * 2);
 
va_start(ap, fmt);
strbuf_vaddf(o-obuf, fmt, ap);
diff --git a/pretty.c b/pretty.c
index 44b9f64..5971415 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1395,9 +1395,7 @@ static size_t format_and_pad_commit(struct strbuf *sb, /* 
in UTF-8 */
 * convert it back to chars
 */
padding = padding - len + local_sb.len;
-   strbuf_grow(sb, padding);
-   strbuf_setlen(sb, sb_len + padding);
-   memset(sb-buf + sb_len, ' ', sb-len - sb_len);
+   strbuf_addchars(sb, ' ', padding);
memcpy(sb-buf + sb_len + offset, local_sb.buf,
   local_sb.len);
}
@@ -1672,10 +1670,8 @@ void pp_remainder(struct pretty_print_context *pp,
first = 0;
 
strbuf_grow(sb, linelen + indent + 20);
-   if (indent) {
-   memset(sb-buf + sb-len, ' ', indent);
-   strbuf_setlen(sb, sb-len + indent);
-   }
+   if (indent)
+   strbuf_addchars(sb, ' ', indent);
strbuf_add(sb, line, linelen);
strbuf_addch(sb, '\n');
}
-- 
2.1.0

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


Re: [PATCH] git-svn.txt: Remove mentions of repack options

2014-09-07 Thread Eric Wong
Lawrence Velázquez v...@larryv.me wrote:
 Git no longer seems to use these flags or their associated config keys;
 when they are present, git-svn outputs a message indicating that they
 are being ignored.
 
 Signed-off-by: Lawrence Velázquez v...@larryv.me

Thanks, will queue.

Signed-off-by: Eric Wong normalper...@yhbt.net
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] git svn: info: correctly handle absolute path args

2014-09-07 Thread Eric Wong
Calling git svn info $(pwd) would hit:
  Reading from filehandle failed at ...
errors due to improper prefixing and canonicalization.

Strip the toplevel path from absolute filesystem paths to ensure
downstream canonicalization routines are only exposed to paths
tracked in git (or SVN).

Thanks to Andrej Manduch amand...@gmail.com for originally
noticing the issue and fixing my original version of this to handle
more corner cases such as /path/to/top/../top and
/path/to/top/../top/file as shown in the new test cases.

Signed-off-by: Andrej Manduch amand...@gmail.com
Signed-off-by: Eric Wong normalper...@yhbt.net
---
Eric Wong normalper...@yhbt.net wrote:
 Thanks Andrej.  I'll queue that on top of mine.
 Can you turn that into a proper commit message with Subject?
 Thanks.

I just squashed in your change and gave you credit.
Sorry, I forgot about this completely.  Will test a bit more
and ask Junio to pull.

 git-svn.perl| 22 --
 t/t9119-git-svn-info.sh | 30 ++
 2 files changed, 46 insertions(+), 6 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index 1f41ee1..47cd6ea 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -1477,10 +1477,20 @@ sub cmd_commit_diff {
}
 }
 
-
 sub cmd_info {
-   my $path = canonicalize_path(defined($_[0]) ? $_[0] : .);
-   my $fullpath = canonicalize_path($cmd_dir_prefix . $path);
+   my $path_arg = defined($_[0]) ? $_[0] : '.';
+   my $path = $path_arg;
+   if ($path =~ m!\A/!) {
+   my $toplevel = eval {
+   my @cmd = qw/rev-parse --show-toplevel/;
+   command_oneline(\@cmd, STDERR = 0);
+   };
+   $path = canonicalize_path($path);
+   $path =~ s!\A\Q$toplevel\E/?!!;
+   $path = canonicalize_path($path);
+   } else {
+   $path = canonicalize_path($cmd_dir_prefix . $path);
+   }
if (exists $_[1]) {
die Too many arguments specified\n;
}
@@ -1501,14 +1511,14 @@ sub cmd_info {
# canonicalize_path() will return  to make libsvn 1.5.x happy,
$path = . if $path eq ;
 
-   my $full_url = canonicalize_url( add_path_to_url( $url, $fullpath ) );
+   my $full_url = canonicalize_url( add_path_to_url( $url, $path ) );
 
if ($_url) {
print $full_url\n;
return;
}
 
-   my $result = Path: $path\n;
+   my $result = Path: $path_arg\n;
$result .= Name:  . basename($path) . \n if $file_type ne dir;
$result .= URL: $full_url\n;
 
@@ -1539,7 +1549,7 @@ sub cmd_info {
}
 
my ($lc_author, $lc_rev, $lc_date_utc);
-   my @args = Git::SVN::Log::git_svn_log_cmd($rev, $rev, --, $fullpath);
+   my @args = Git::SVN::Log::git_svn_log_cmd($rev, $rev, --, $path);
my $log = command_output_pipe(@args);
my $esc_color = qr/(?:\033\[(?:(?:\d+;)*\d*)?m)*/;
while ($log) {
diff --git a/t/t9119-git-svn-info.sh b/t/t9119-git-svn-info.sh
index ff19695..f16f323 100755
--- a/t/t9119-git-svn-info.sh
+++ b/t/t9119-git-svn-info.sh
@@ -74,6 +74,36 @@ test_expect_success 'info .' 
test_cmp_info expected.info-dot actual.info-dot

 
+test_expect_success 'info $(pwd)' '
+   (cd svnwc; svn info $(pwd)) expected.info-pwd 
+   (cd gitwc; git svn info $(pwd)) actual.info-pwd 
+   grep -v ^Path: expected.info-pwd expected.info-np 
+   grep -v ^Path: actual.info-pwd actual.info-np 
+   test_cmp_info expected.info-np actual.info-np 
+   test $(sed -ne \/^Path:/ s!/svnwc!!\ expected.info-pwd) = \
+$(sed -ne \/^Path:/ s!/gitwc!!\ actual.info-pwd)
+   '
+
+test_expect_success 'info $(pwd)/../___wc' '
+   (cd svnwc; svn info $(pwd)/../svnwc) expected.info-pwd 
+   (cd gitwc; git svn info $(pwd)/../gitwc) actual.info-pwd 
+   grep -v ^Path: expected.info-pwd expected.info-np 
+   grep -v ^Path: actual.info-pwd actual.info-np 
+   test_cmp_info expected.info-np actual.info-np 
+   test $(sed -ne \/^Path:/ s!/svnwc!!\ expected.info-pwd) = \
+$(sed -ne \/^Path:/ s!/gitwc!!\ actual.info-pwd)
+   '
+
+test_expect_success 'info $(pwd)/../___wc//file' '
+   (cd svnwc; svn info $(pwd)/../svnwc//file) expected.info-pwd 
+   (cd gitwc; git svn info $(pwd)/../gitwc//file) actual.info-pwd 
+   grep -v ^Path: expected.info-pwd expected.info-np 
+   grep -v ^Path: actual.info-pwd actual.info-np 
+   test_cmp_info expected.info-np actual.info-np 
+   test $(sed -ne \/^Path:/ s!/svnwc!!\ expected.info-pwd) = \
+$(sed -ne \/^Path:/ s!/gitwc!!\ actual.info-pwd)
+   '
+
 test_expect_success 'info --url .' '
test $(cd gitwc; git svn info --url .) = $quoted_svnrepo
'
-- 
EW
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info 

[PATCH] git svn: find-rev allows short switches for near matches

2014-09-07 Thread Eric Wong
Allow -B and -A to act as short aliases for --before and --after
options respectively.  This reduces typing and hopefully allows
reuse of muscle memory for grep(1) users.

Signed-off-by: Eric Wong normalper...@yhbt.net
---
 Will push to git://bogomips.org/git-svn.git

 Documentation/git-svn.txt | 2 ++
 git-svn.perl  | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index 14036cf..ef8ef1c 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -386,11 +386,13 @@ Any other arguments are passed directly to 'git log'
tree-ish to specify which branch should be searched).  When given a
tree-ish, returns the corresponding SVN revision number.
 +
+-B;;
 --before;;
Don't require an exact match if given an SVN revision, instead find
the commit corresponding to the state of the SVN repository (on the
current branch) at the specified revision.
 +
+-A;;
 --after;;
Don't require an exact match if given an SVN revision; if there is
not an exact match return the closest match searching forward in the
diff --git a/git-svn.perl b/git-svn.perl
index 47cd6ea..a0ca31d 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -260,8 +260,8 @@ my %cmd = (
} ],
'find-rev' = [ \cmd_find_rev,
Translate between SVN revision numbers and tree-ish,
-   { 'before' = \$_before,
- 'after' = \$_after } ],
+   { 'B|before' = \$_before,
+ 'A|after' = \$_after } ],
'rebase' = [ \cmd_rebase, Fetch and rebase your working directory,
{ 'merge|m|M' = \$_merge,
  'verbose|v' = \$_verbose,
-- 
EW
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] git svn: info: correctly handle absolute path args

2014-09-07 Thread Johannes Sixt
Am 07.09.2014 10:06, schrieb Eric Wong:
 diff --git a/git-svn.perl b/git-svn.perl
 index 1f41ee1..47cd6ea 100755
 --- a/git-svn.perl
 +++ b/git-svn.perl
 @@ -1477,10 +1477,20 @@ sub cmd_commit_diff {
   }
  }
  
 -
  sub cmd_info {
 - my $path = canonicalize_path(defined($_[0]) ? $_[0] : .);
 - my $fullpath = canonicalize_path($cmd_dir_prefix . $path);
 + my $path_arg = defined($_[0]) ? $_[0] : '.';
 + my $path = $path_arg;
 + if ($path =~ m!\A/!) {

There must be a more portable way to check for an absolute path. Think
of DOS-style paths...

 + my $toplevel = eval {
 + my @cmd = qw/rev-parse --show-toplevel/;
 + command_oneline(\@cmd, STDERR = 0);
 + };
 + $path = canonicalize_path($path);
 + $path =~ s!\A\Q$toplevel\E/?!!;
 + $path = canonicalize_path($path);
 + } else {
 + $path = canonicalize_path($cmd_dir_prefix . $path);
 + }
   if (exists $_[1]) {
   die Too many arguments specified\n;
   }

-- Hannes

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


[PATCH v3 2/2] headers: include dependent headers

2014-09-07 Thread David Aguilar
Add dependent headers so that including a header does not
require including additional headers.

This makes it so that gcc -c $header succeeds for each header.

Helped-by: René Scharfe l@web.de
Signed-off-by: David Aguilar dav...@gmail.com
---
Replacement patch with René's suggestions squashed in.

 archive.h| 1 +
 argv-array.h | 2 ++
 attr.h   | 2 ++
 branch.h | 2 ++
 builtin.h| 1 -
 cache-tree.h | 1 +
 cache.h  | 1 -
 color.h  | 3 ++-
 column.h | 2 ++
 commit.h | 2 +-
 compat/bswap.h   | 7 +++
 compat/precompose_utf8.h | 8 +++-
 convert.h| 3 +++
 credential.h | 1 +
 csum-file.h  | 2 ++
 delta.h  | 2 ++
 diff.h   | 2 +-
 diffcore.h   | 2 ++
 dir.h| 3 ++-
 ewah/ewok.h  | 2 ++
 ewah/ewok_rlw.h  | 2 ++
 exec_cmd.h   | 2 ++
 fsck.h   | 2 ++
 gpg-interface.h  | 2 ++
 graph.h  | 2 ++
 hashmap.h| 2 ++
 help.h   | 2 ++
 khash.h  | 2 ++
 kwset.h  | 2 ++
 line-log.h   | 1 +
 list-objects.h   | 2 ++
 ll-merge.h   | 2 ++
 mailmap.h| 3 +++
 merge-recursive.h| 2 ++
 notes-cache.h| 1 +
 notes-merge.h| 3 +++
 notes-utils.h| 1 +
 notes.h  | 1 +
 object.h | 2 ++
 pack-bitmap.h| 2 ++
 pack-objects.h   | 2 ++
 pack-revindex.h  | 2 ++
 parse-options.h  | 2 ++
 patch-ids.h  | 3 +++
 pathspec.h   | 2 ++
 progress.h   | 2 ++
 quote.h  | 3 ++-
 reachable.h  | 2 ++
 reflog-walk.h| 1 +
 refs.h   | 4 
 remote.h | 1 +
 resolve-undo.h   | 2 ++
 send-pack.h  | 4 
 sequencer.h  | 3 +++
 sha1-lookup.h| 2 ++
 shortlog.h   | 2 ++
 sideband.h   | 2 ++
 strbuf.h | 2 ++
 submodule.h  | 6 --
 tag.h| 1 +
 tree-walk.h  | 2 ++
 tree.h   | 1 +
 unicode_width.h  | 3 +++
 unpack-trees.h   | 2 ++
 url.h| 2 ++
 urlmatch.h   | 2 ++
 utf8.c   | 7 ---
 utf8.h   | 9 +
 vcs-svn/fast_export.h| 5 +++--
 vcs-svn/repo_tree.h  | 3 ++-
 vcs-svn/svndiff.h| 5 +++--
 wt-status.h  | 1 +
 xdiff/xdiffi.h   | 2 ++
 xdiff/xemit.h| 1 +
 xdiff/xprepare.h | 2 ++
 xdiff/xutils.h   | 2 ++
 76 files changed, 158 insertions(+), 26 deletions(-)

diff --git a/archive.h b/archive.h
index 4a791e1..b2ca5bf 100644
--- a/archive.h
+++ b/archive.h
@@ -1,6 +1,7 @@
 #ifndef ARCHIVE_H
 #define ARCHIVE_H
 
+#include cache.h
 #include pathspec.h
 
 struct archiver_args {
diff --git a/argv-array.h b/argv-array.h
index c65e6e8..7d877af 100644
--- a/argv-array.h
+++ b/argv-array.h
@@ -1,6 +1,8 @@
 #ifndef ARGV_ARRAY_H
 #define ARGV_ARRAY_H
 
+#include git-compat-util.h
+
 extern const char *empty_argv[];
 
 struct argv_array {
diff --git a/attr.h b/attr.h
index 8b08d33..34e63f8 100644
--- a/attr.h
+++ b/attr.h
@@ -1,6 +1,8 @@
 #ifndef ATTR_H
 #define ATTR_H
 
+#include cache.h
+
 /* An attribute is a pointer to this opaque structure */
 struct git_attr;
 
diff --git a/branch.h b/branch.h
index 64173ab..d5fdcc6 100644
--- a/branch.h
+++ b/branch.h
@@ -3,6 +3,8 @@
 
 /* Functions for acting on the information about branches. */
 
+#include cache.h
+
 /*
  * Creates a new branch, where head is the branch currently checked
  * out, name is the new branch name, start_name is the name of the
diff --git a/builtin.h b/builtin.h
index 5d91f31..07c9328 100644
--- a/builtin.h
+++ b/builtin.h
@@ -1,7 +1,6 @@
 #ifndef BUILTIN_H
 #define BUILTIN_H
 
-#include git-compat-util.h
 #include strbuf.h
 #include cache.h
 #include commit.h
diff --git a/cache-tree.h b/cache-tree.h
index b47ccec..30b0775 100644
--- a/cache-tree.h
+++ b/cache-tree.h
@@ -3,6 +3,7 @@
 
 #include tree.h
 #include tree-walk.h
+#include cache.h
 
 struct cache_tree;
 struct cache_tree_sub {
diff --git a/cache.h b/cache.h
index 4d5b76c..8b827d7 100644
--- a/cache.h
+++ b/cache.h
@@ -1,7 +1,6 @@
 #ifndef CACHE_H
 #define CACHE_H
 
-#include git-compat-util.h
 #include strbuf.h
 #include hashmap.h
 #include advice.h
diff --git a/color.h b/color.h
index 9a8495b..6b50a0f 100644
--- a/color.h
+++ b/color.h
@@ -1,7 +1,8 @@
 #ifndef COLOR_H
 #define COLOR_H
 
-struct strbuf;
+#include git-compat-util.h
+#include strbuf.h
 
 /*  2 + (2 * num_attrs) + 8 + 1 + 8 + 'm' + NUL */
 /* \033[1;2;4;5;7;38;5;2xx;48;5;2xxm\0 */
diff --git a/column.h b/column.h
index 0a61917..5d094b4 

Re: [PATCH v3 2/2] headers: include dependent headers

2014-09-07 Thread René Scharfe

Am 07.09.2014 um 11:36 schrieb David Aguilar:

Add dependent headers so that including a header does not
require including additional headers.

This makes it so that gcc -c $header succeeds for each header.



diff --git a/cache.h b/cache.h
index 4d5b76c..8b827d7 100644
--- a/cache.h
+++ b/cache.h
@@ -1,7 +1,6 @@
  #ifndef CACHE_H
  #define CACHE_H

-#include git-compat-util.h
  #include strbuf.h
  #include hashmap.h
  #include advice.h


Oh, that's a new change and worth mentioning in the commit message.


diff --git a/color.h b/color.h
index 9a8495b..6b50a0f 100644
--- a/color.h
+++ b/color.h
@@ -1,7 +1,8 @@
  #ifndef COLOR_H
  #define COLOR_H

-struct strbuf;
+#include git-compat-util.h
+#include strbuf.h

  /*  2 + (2 * num_attrs) + 8 + 1 + 8 + 'm' + NUL */
  /* \033[1;2;4;5;7;38;5;2xx;48;5;2xxm\0 */


I didn't notice this one the first time around.  Isn't the forward
declaration of struct strbuf enough?


diff --git a/diff.h b/diff.h
index b4a624d..27f7696 100644
--- a/diff.h
+++ b/diff.h
@@ -6,11 +6,11 @@

  #include tree-walk.h
  #include pathspec.h
+#include strbuf.h

  struct rev_info;
  struct diff_options;
  struct diff_queue_struct;
-struct strbuf;
  struct diff_filespec;
  struct userdiff_driver;
  struct sha1_array;


Same here.


diff --git a/quote.h b/quote.h
index 71dcc3a..37f857b 100644
--- a/quote.h
+++ b/quote.h
@@ -1,7 +1,8 @@
  #ifndef QUOTE_H
  #define QUOTE_H

-struct strbuf;
+#include git-compat-util.h
+#include strbuf.h

  /* Help to copy the thing properly quoted for the shell safety.
   * any single quote is replaced with '\'', any exclamation point


And here.

 diff --git a/submodule.h b/submodule.h
 index 7beec48..52bb673 100644
 --- a/submodule.h
 +++ b/submodule.h
 @@ -1,8 +1,10 @@
   #ifndef SUBMODULE_H
   #define SUBMODULE_H

 -struct diff_options;
 -struct argv_array;
 +#include git-compat-util.h
 +#include diff.h
 +#include argv-array.h
 +#include string-list.h

   enum {
RECURSE_SUBMODULES_ON_DEMAND = -1,

Similarly here with structs diff_options and argv_array.


diff --git a/utf8.c b/utf8.c
index b30790d..fb9f299 100644
--- a/utf8.c
+++ b/utf8.c
@@ -2,13 +2,6 @@
  #include strbuf.h
  #include utf8.h

-/* This code is originally from http://www.cl.cam.ac.uk/~mgk25/ucs/ */
-
-struct interval {
-   ucs_char_t first;
-   ucs_char_t last;
-};
-
  size_t display_mode_esc_sequence_len(const char *s)
  {
const char *p = s;
diff --git a/utf8.h b/utf8.h
index 65d0e42..af855c5 100644
--- a/utf8.h
+++ b/utf8.h
@@ -1,8 +1,17 @@
  #ifndef GIT_UTF8_H
  #define GIT_UTF8_H

+#include strbuf.h
+
  typedef unsigned int ucs_char_t;  /* assuming 32bit int */

+/* This code is originally from http://www.cl.cam.ac.uk/~mgk25/ucs/ */
+
+struct interval {
+   ucs_char_t first;
+   ucs_char_t last;
+};
+
  size_t display_mode_esc_sequence_len(const char *s);
  int utf8_width(const char **start, size_t *remainder_p);
  int utf8_strnwidth(const char *string, int len, int skip_ansi);


The move of struct interval was mentioned in the comment section of
the first patch.  Perhaps include a note in the commit message?


diff --git a/vcs-svn/fast_export.h b/vcs-svn/fast_export.h
index c8b5adb..7fd5364 100644
--- a/vcs-svn/fast_export.h
+++ b/vcs-svn/fast_export.h
@@ -1,8 +1,9 @@
  #ifndef FAST_EXPORT_H_
  #define FAST_EXPORT_H_

-struct strbuf;
-struct line_buffer;
+#include git-compat-util.h
+#include strbuf.h
+#include vcs-svn/line_buffer.h

  void fast_export_init(int fd);
  void fast_export_deinit(void);


struct strbuf forward declaration vs. including strbuf.h again.


diff --git a/vcs-svn/repo_tree.h b/vcs-svn/repo_tree.h
index 889c6a3..3a946f7 100644
--- a/vcs-svn/repo_tree.h
+++ b/vcs-svn/repo_tree.h
@@ -1,7 +1,8 @@
  #ifndef REPO_TREE_H_
  #define REPO_TREE_H_

-struct strbuf;
+#include git-compat-util.h
+#include strbuf.h

  #define REPO_MODE_DIR 004
  #define REPO_MODE_BLB 0100644


And again.


diff --git a/vcs-svn/svndiff.h b/vcs-svn/svndiff.h
index 74eb464..d0cbd51 100644
--- a/vcs-svn/svndiff.h
+++ b/vcs-svn/svndiff.h
@@ -1,8 +1,9 @@
  #ifndef SVNDIFF_H_
  #define SVNDIFF_H_

-struct line_buffer;
-struct sliding_view;
+#include git-compat-util.h
+#include vcs-svn/line_buffer.h
+#include vcs-svn/sliding_window.h

  extern int svndiff0_apply(struct line_buffer *delta, off_t delta_len,
struct sliding_view *preimage, FILE *postimage);


Similar issue here with different structs.
--
To unsubscribe from this list: send the line 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 2/2] headers: include dependent headers

2014-09-07 Thread Ramsay Jones
On 07/09/14 11:35, René Scharfe wrote:
 Am 07.09.2014 um 11:36 schrieb David Aguilar:
 Add dependent headers so that including a header does not
 require including additional headers.

 This makes it so that gcc -c $header succeeds for each header.
 
 diff --git a/cache.h b/cache.h
 index 4d5b76c..8b827d7 100644
 --- a/cache.h
 +++ b/cache.h
 @@ -1,7 +1,6 @@
   #ifndef CACHE_H
   #define CACHE_H

 -#include git-compat-util.h
   #include strbuf.h
   #include hashmap.h
   #include advice.h
 
 Oh, that's a new change and worth mentioning in the commit message.

Hmm, does this not break git? Unless you also change each '.c' file which
includes cache.h to also include git-compat-util.h first, then I suspect
(if nothing else) file I/O may be broken. (see _FILE_OFFSET_BITS).

Also, see Documentation/CodingGuidelines (lines 331-333).

ATB,
Ramsay Jones



--
To unsubscribe from this list: send the line 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 v4 00/32] Lockfile correctness and refactoring

2014-09-07 Thread Torsten Bögershausen

On 2014-09-06 09.50, Michael Haggerty wrote:
 Sorry for the long delay since v3. This version mostly cleans up a
 couple more places where the lockfile object was left in an
 ill-defined state. 
No problem with the delay.
The most important question is if we do the lk-active handling right.
Set it to false as seen as possible, and to true as late as possible,
then die() cleanly.
So the -acive handling looks (more or less, please see below) and
deserves another critical review, may be.

Instead of commenting each patch, I collected a mixture of small questions
and possible suggestions into a diff file.

diff --git a/lockfile.c b/lockfile.c
index e54d260..7f27ea2 100644
--- a/lockfile.c
+++ b/lockfile.c
@@ -18,6 +18,10 @@
  *Usually, if $FILENAME is a symlink, then it is resolved, and the
  *file ultimately pointed to is the one that is locked and later
  *replaced.  However, if LOCK_NODEREF is used, then $FILENAME
+LOCK_NODEREF can be read either as
+LOCK_NODE_REF or LOCK_NO_DEREF
+should we change it ?
+
  *itself is locked and later replaced, even if it is a symlink.
  *
  * 2. Write the new file contents to the lockfile.
@@ -46,9 +50,18 @@
  *   state:
  *   - the lockfile exists
  *   - active is set
- *   - filename holds the filename of the lockfile
+ *   - filename holds the filename of the lockfile in a strbuf
  *   - fd holds a file descriptor open for writing to the lockfile
  *   - owner holds the PID of the process that locked the file
+question: Why do we need the PID here ?
+Do we open a lock file and do a fork() ?
+And if yes, the child gets a new PID, what happens when the
+child gets a signal ?
+Who owns the lockfile, the parent, the child, both ?
+The child has access to all data, the fd is open and can be used,
+why do we not allow a rollback, when the child dies ?
+
+
  *
  * - Locked, lockfile closed (after close_lock_file()).  Same as the
  *   previous state, except that the lockfile is closed and fd is -1.
@@ -57,7 +70,7 @@
  *   rollback_lock_file(), or a failed attempt to lock).  In this
  *   state:
  *   - active is unset
- *   - filename is the empty string (usually, though there are
+ *   - filename is an empty string buffer (usually, though there are
  * transitory states in which this condition doesn't hold)
  *   - fd is -1
  *   - the object is left registered in the lock_file_list, and
@@ -68,7 +81,7 @@
 
 static struct lock_file *volatile lock_file_list;
 
-static void remove_lock_file(void)
+static void remove_lock_files(void)
 {
 pid_t me = getpid();
 
@@ -79,9 +92,9 @@ static void remove_lock_file(void)
 }
 }
 
-static void remove_lock_file_on_signal(int signo)
+static void remove_lock_files_on_signal(int signo)
 {
-remove_lock_file();
+remove_lock_files();
 sigchain_pop(signo);
 raise(signo);
 }
@@ -93,7 +106,7 @@ static void remove_lock_file_on_signal(int signo)
  * /, if any).  If path is empty or the root directory (/), set
  * path to the empty string.
  */
-static void trim_last_path_elm(struct strbuf *path)
+static void trim_last_path_elem(struct strbuf *path)
 {
 int i = path-len;
 
@@ -143,7 +156,7 @@ static void resolve_symlink(struct strbuf *path)
  * link is a relative path, so replace the
  * last element of p with it.
  */
-trim_last_path_elm(path);
+trim_last_path_elem(path);
 
 strbuf_addbuf(path, link);
 }
@@ -153,13 +166,16 @@ static void resolve_symlink(struct strbuf *path)
 /* Make sure errno contains a meaningful value on error */
 static int lock_file(struct lock_file *lk, const char *path, int flags)
 {
+struct stat st;
+int mode = 0666;
 if (!lock_file_list) {
 /* One-time initialization */
-sigchain_push_common(remove_lock_file_on_signal);
-atexit(remove_lock_file);
+sigchain_push_common(remove_lock_files_on_signal);
+atexit(remove_lock_files);
 }
 
-assert(!lk-active);
+  if (lk-active)
+die(lk-active %s, path);
 
 if (!lk-on_list) {
 /* Initialize *lk and add it to lock_file_list: */
@@ -167,16 +183,25 @@ static int lock_file(struct lock_file *lk, const char 
*path, int flags)
 lk-active = 0;
 lk-owner = 0;
 lk-on_list = 1;
-strbuf_init(lk-filename, 0);
+strbuf_init(lk-filename, strlen(path) + LOCK_SUFFIX_LEN);
 lk-next = lock_file_list;
 lock_file_list = lk;
 }
 
+strbuf_reset(lk-filename); /* Better to be save */
 strbuf_addstr(lk-filename, path);
 if (!(flags  LOCK_NODEREF))
 resolve_symlink(lk-filename);
 strbuf_addstr(lk-filename, LOCK_SUFFIX);
-lk-fd = open(lk-filename.buf, O_RDWR | O_CREAT | O_EXCL, 0666);
+/*
+ * adjust_shared_perm() will widen permissions if needed,
+ * otherwise keep permissions restrictive
+ *
+ */
+if (!stat(path, st))
+mode = st.st_mode  0;
+
+lk-fd = open(lk-filename.buf, O_RDWR | O_CREAT 

Re: trace.c, line 219: error: identifier redeclared: trace_strbuf

2014-09-07 Thread dev


On September 6, 2014 at 4:53 PM René Scharfe l@web.de wrote:
 Am 06.09.2014 um 21:26 schrieb dev:
 
 
snip
 
  Solaris 10 with Oracle Studio 12.3 compiler tools. A lengthy
  maillist
  discussion last week sorted out the previous release of git just
  fine however this release fails to build.
 

 The issue was introduced with e05bed96 (trace: add 'file:line' to all
 trace output).

 -- 8 --
 Subject: [PATCH] trace: correct trace_strbuf() parameter type for
 !HAVE_VARIADIC_MACROS

 Reported-by: dev d...@cor0.com
 Signed-off-by: Rene Scharfe l@web.de
 ---
  trace.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/trace.c b/trace.c
 index 54aaee5..b6f25a2 100644
 --- a/trace.c
 +++ b/trace.c
 @@ -216,7 +216,7 @@ void trace_argv_printf(const char **argv, const
 char *format, ...)
va_end(ap);
  }
 
 -void trace_strbuf(const char *key, const struct strbuf *data)
 +void trace_strbuf(struct trace_key *key, const struct strbuf *data)
  {
trace_strbuf_fl(NULL, 0, key, data);
  }
 --
 2.1.0


Thank you for the reply and the info.  I backed that out and things get
worse :

$ diff -h trace.c.backup trace.c
219,221c219,221
 void trace_strbuf(const char *key, const struct strbuf *data)
 {
   trace_strbuf_fl(NULL, 0, key, data);
---
 void trace_strbuf(struct trace_key *key, const struct strbuf *data)
 {
 trace_strbuf_fl(NULL, 0, key, data);


$ gmake CFLAGS=$CFLAGS LDFLAGS=$LD_OPTIONS NEEDS_LIBICONV=Yes \
 SHELL_PATH=/usr/local/bin/bash \
 SANE_TOOL_PATH=/usr/local/bin \
 USE_LIBPCRE=1 LIBPCREDIR=/usr/local CURLDIR=/usr/local \
 EXPATDIR=/usr/local NEEDS_LIBINTL_BEFORE_LIBICONV=1 \
 NEEDS_SOCKET=1 NEEDS_RESOLV=1 USE_NSEC=1 \
 PERL_PATH=/usr/local/bin/perl \
 TAR=/usr/bin/tar \
 NO_PYTHON=1 DEFAULT_PAGER=/usr/xpg4/bin/more \
 DEFAULT_EDITOR=/usr/local/bin/vim DEFAULT_HELP_FORMAT=man \
 prefix=/usr/local
CC trace.o
trace.c, line 390: error: reference to static identifier offset in
extern inline function
trace.c, line 392: error: reference to static identifier offset in
extern inline function
trace.c, line 393: error: reference to static identifier offset in
extern inline function
trace.c, line 401: error: reference to static identifier offset in
extern inline function
trace.c, line 403: error: reference to static identifier offset in
extern inline function
cc: acomp failed for trace.c
gmake: *** [trace.o] Error 2
$

So is there a possible 2.1.1 coming along shortly ?

dev
--
To unsubscribe from this list: send the line 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: [RFC PATCH v2 1/2] Makefile: add check-headers target

2014-09-07 Thread Jonathan Nieder
Hi,

David Aguilar wrote:

 --- /dev/null
 +++ b/check-headers.sh
 @@ -0,0 +1,29 @@
[...]
 + $@ -Wno-unused -I$subdir -c -o $header.check -x c - $header 

All .c files in git are supposed to start by #include-ing
git-compat-util.h, cache.h, or builtin.h to set the appropriate
feature test macros and include system headers.

Headers rely on that for basic types like int32_t.  They don't need to
include git-compat-util.h because the .c file that included them would
have already, and .h files #include-ed by git-compat-util.h especially
*shouldn't* #include the compat header, so how about something like
the following for squashing in?

A side-thought: as long as we're building pre-compiled headers, could
we use them in the build?

Thanks,
Jonathan

diff --git a/check-headers.sh b/check-headers.sh
index bf85c41..08ca136 100755
--- a/check-headers.sh
+++ b/check-headers.sh
@@ -18,7 +18,7 @@ git ls-files *.h |
 while read header
 do
echo HEADER $header 
-   $@ -Wno-unused -x c -c -o $header.bin - $header 
+   $@ -Wno-unused -x c -include git-compat-util.h -c -o $header.bin - 
$header 
rm $header.bin ||
maybe_exit $?
 done
--
To unsubscribe from this list: send the line 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: [RFC PATCH v2 2/2] headers: include dependent headers

2014-09-07 Thread Jonathan Nieder
David Aguilar wrote:

 Add dependent headers so that including a header does not
 require including additional headers.

I agree with this goal, modulo the compat-util.h caveat.  Thanks
for working on it.

[...]
 --- a/archive.h
 +++ b/archive.h
 @@ -1,6 +1,7 @@
  #ifndef ARCHIVE_H
  #define ARCHIVE_H
  
 +#include cache.h
  #include pathspec.h
  
  struct archiver_args {

I'm less happy about the way of achieving that goal.  Here's an
alternative.  Advantages:

 * (fully expanded) headers stay small

 * fewer other headers included as a side-effect of including one
   header, so callers are more likely to remember to #include the
   headers defining things they need (which makes later refactoring
   easier)

 * circular header dependencies are harder to produce

If this seems like a good direction to go in, I can finish the patch
later today (or I don't mind if someone else takes care of it).  This
is just to give the idea --- I stopped at dir.h.

Sensible?
Jonathan

diff --git i/archive.h w/archive.h
index 4a791e1..11f4d42 100644
--- i/archive.h
+++ w/archive.h
@@ -3,6 +3,9 @@
 
 #include pathspec.h
 
+enum object_type;
+
+
 struct archiver_args {
const char *base;
size_t baselen;
diff --git i/attr.h w/attr.h
index 8b08d33..c971ef2 100644
--- i/attr.h
+++ w/attr.h
@@ -1,6 +1,8 @@
 #ifndef ATTR_H
 #define ATTR_H
 
+struct index_state;
+
 /* An attribute is a pointer to this opaque structure */
 struct git_attr;
 
diff --git i/branch.h w/branch.h
index 64173ab..ed63209 100644
--- i/branch.h
+++ w/branch.h
@@ -1,6 +1,9 @@
 #ifndef BRANCH_H
 #define BRANCH_H
 
+enum branch_track;
+struct strbuf;
+
 /* Functions for acting on the information about branches. */
 
 /*
diff --git i/cache-tree.h w/cache-tree.h
index b47ccec..c22e2ec 100644
--- i/cache-tree.h
+++ w/cache-tree.h
@@ -1,8 +1,12 @@
 #ifndef CACHE_TREE_H
 #define CACHE_TREE_H
 
-#include tree.h
-#include tree-walk.h
+struct traverse_info;
+struct index_state;
+struct name_entry;
+struct tree;
+struct string_list;
+struct strbuf;
 
 struct cache_tree;
 struct cache_tree_sub {
diff --git i/column.h w/column.h
index 0a61917..8211386 100644
--- i/column.h
+++ w/column.h
@@ -1,6 +1,9 @@
 #ifndef COLUMN_H
 #define COLUMN_H
 
+struct option;
+struct string_list;
+
 #define COL_LAYOUT_MASK   0x000F
 #define COL_ENABLE_MASK   0x0030   /* always, never or auto */
 #define COL_PARSEOPT  0x0040   /* --column is given from cmdline */
@@ -26,7 +29,6 @@ struct column_options {
const char *nl;
 };
 
-struct option;
 extern int parseopt_column_callback(const struct option *, const char *, int);
 extern int git_column_config(const char *var, const char *value,
 const char *command, unsigned int *colopts);
diff --git i/commit.h w/commit.h
index aa8c3ca..d2fd182 100644
--- i/commit.h
+++ w/commit.h
@@ -1,13 +1,18 @@
 #ifndef COMMIT_H
 #define COMMIT_H
 
+#include cache.h
 #include object.h
-#include tree.h
-#include strbuf.h
-#include decorate.h
-#include gpg-interface.h
+#include trace.h
 #include string-list.h
 
+struct reflog_walk_info;
+struct rev_info;
+struct ref;
+struct signature_check;
+struct sha1_array;
+struct strbuf;
+
 struct commit_list {
struct commit *item;
struct commit_list *next;
@@ -151,7 +156,6 @@ struct userformat_want {
 };
 
 extern int has_non_ascii(const char *text);
-struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
 extern const char *logmsg_reencode(const struct commit *commit,
   char **commit_encoding,
   const char *output_encoding);
@@ -231,8 +235,6 @@ extern struct commit_list *get_octopus_merge_bases(struct 
commit_list *in);
 /* largest positive number a signed 32-bit integer can contain */
 #define INFINITE_DEPTH 0x7fff
 
-struct sha1_array;
-struct ref;
 extern int register_shallow(const unsigned char *sha1);
 extern int unregister_shallow(const unsigned char *sha1);
 extern int for_each_commit_graft(each_commit_graft_fn, void *);
diff --git i/convert.h w/convert.h
index 0c2143c..e623527 100644
--- i/convert.h
+++ w/convert.h
@@ -4,6 +4,8 @@
 #ifndef CONVERT_H
 #define CONVERT_H
 
+struct strbuf;
+
 enum safe_crlf {
SAFE_CRLF_FALSE = 0,
SAFE_CRLF_FAIL = 1,
diff --git i/csum-file.h w/csum-file.h
index bb543d5..9e29e35 100644
--- i/csum-file.h
+++ w/csum-file.h
@@ -1,6 +1,8 @@
 #ifndef CSUM_FILE_H
 #define CSUM_FILE_H
 
+#include cache.h
+
 struct progress;
 
 /* A SHA1-protected file */
diff --git i/diffcore.h w/diffcore.h
index c876dac..96fc827 100644
--- i/diffcore.h
+++ w/diffcore.h
@@ -4,6 +4,9 @@
 #ifndef DIFFCORE_H
 #define DIFFCORE_H
 
+struct userdiff_driver;
+struct diff_options;
+
 /* This header file is internal between diff.c and its diff transformers
  * (e.g. diffcore-rename, diffcore-pickaxe).  Never include this header
  * in anything else.
@@ -22,8 +25,6 @@
 
 #define MINIMUM_BREAK_SIZE 400 /* do not break a file smaller than this */
 

Re: [RFC PATCH v2 2/2] headers: include dependent headers

2014-09-07 Thread Johannes Sixt
Am 07.09.2014 21:49, schrieb Jonathan Nieder:
 +enum object_type;

Enum forward declarations are a relatively new C feature. They certainly
don't exist pre-C99.

-- Hannes

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


Re: [RFC PATCH v2 2/2] headers: include dependent headers

2014-09-07 Thread Jonathan Nieder
Johannes Sixt wrote:
 Am 07.09.2014 21:49, schrieb Jonathan Nieder:

 +enum object_type;

 Enum forward declarations are a relatively new C feature. They certainly
 don't exist pre-C99.

Good catch.  That makes

diff --git i/archive.h w/archive.h
index 4a791e1..b2ca5bf 100644
--- i/archive.h
+++ w/archive.h
@@ -1,6 +1,7 @@
 #ifndef ARCHIVE_H
 #define ARCHIVE_H
 
+#include cache.h
 #include pathspec.h
 
 struct archiver_args {
diff --git i/attr.h w/attr.h
index 8b08d33..c971ef2 100644
--- i/attr.h
+++ w/attr.h
@@ -1,6 +1,8 @@
 #ifndef ATTR_H
 #define ATTR_H
 
+struct index_state;
+
 /* An attribute is a pointer to this opaque structure */
 struct git_attr;
 
diff --git i/branch.h w/branch.h
index 64173ab..5ce6e21 100644
--- i/branch.h
+++ w/branch.h
@@ -1,6 +1,8 @@
 #ifndef BRANCH_H
 #define BRANCH_H
 
+#include cache.h
+
 /* Functions for acting on the information about branches. */
 
 /*
diff --git i/cache-tree.h w/cache-tree.h
index b47ccec..c22e2ec 100644
--- i/cache-tree.h
+++ w/cache-tree.h
@@ -1,8 +1,12 @@
 #ifndef CACHE_TREE_H
 #define CACHE_TREE_H
 
-#include tree.h
-#include tree-walk.h
+struct traverse_info;
+struct index_state;
+struct name_entry;
+struct tree;
+struct string_list;
+struct strbuf;
 
 struct cache_tree;
 struct cache_tree_sub {
diff --git i/column.h w/column.h
index 0a61917..8211386 100644
--- i/column.h
+++ w/column.h
@@ -1,6 +1,9 @@
 #ifndef COLUMN_H
 #define COLUMN_H
 
+struct option;
+struct string_list;
+
 #define COL_LAYOUT_MASK   0x000F
 #define COL_ENABLE_MASK   0x0030   /* always, never or auto */
 #define COL_PARSEOPT  0x0040   /* --column is given from cmdline */
@@ -26,7 +29,6 @@ struct column_options {
const char *nl;
 };
 
-struct option;
 extern int parseopt_column_callback(const struct option *, const char *, int);
 extern int git_column_config(const char *var, const char *value,
 const char *command, unsigned int *colopts);
diff --git i/commit.h w/commit.h
index aa8c3ca..097fc9e 100644
--- i/commit.h
+++ w/commit.h
@@ -1,13 +1,17 @@
 #ifndef COMMIT_H
 #define COMMIT_H
 
+#include cache.h
 #include object.h
-#include tree.h
-#include strbuf.h
-#include decorate.h
-#include gpg-interface.h
+#include trace.h
 #include string-list.h
 
+struct reflog_walk_info;
+struct rev_info;
+struct ref;
+struct signature_check;
+struct sha1_array;
+
 struct commit_list {
struct commit *item;
struct commit_list *next;
@@ -151,7 +155,6 @@ struct userformat_want {
 };
 
 extern int has_non_ascii(const char *text);
-struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
 extern const char *logmsg_reencode(const struct commit *commit,
   char **commit_encoding,
   const char *output_encoding);
@@ -231,8 +234,6 @@ extern struct commit_list *get_octopus_merge_bases(struct 
commit_list *in);
 /* largest positive number a signed 32-bit integer can contain */
 #define INFINITE_DEPTH 0x7fff
 
-struct sha1_array;
-struct ref;
 extern int register_shallow(const unsigned char *sha1);
 extern int unregister_shallow(const unsigned char *sha1);
 extern int for_each_commit_graft(each_commit_graft_fn, void *);
diff --git i/convert.h w/convert.h
index 0c2143c..e623527 100644
--- i/convert.h
+++ w/convert.h
@@ -4,6 +4,8 @@
 #ifndef CONVERT_H
 #define CONVERT_H
 
+struct strbuf;
+
 enum safe_crlf {
SAFE_CRLF_FALSE = 0,
SAFE_CRLF_FAIL = 1,
diff --git i/csum-file.h w/csum-file.h
index bb543d5..9e29e35 100644
--- i/csum-file.h
+++ w/csum-file.h
@@ -1,6 +1,8 @@
 #ifndef CSUM_FILE_H
 #define CSUM_FILE_H
 
+#include cache.h
+
 struct progress;
 
 /* A SHA1-protected file */
diff --git i/diffcore.h w/diffcore.h
index c876dac..96fc827 100644
--- i/diffcore.h
+++ w/diffcore.h
@@ -4,6 +4,9 @@
 #ifndef DIFFCORE_H
 #define DIFFCORE_H
 
+struct userdiff_driver;
+struct diff_options;
+
 /* This header file is internal between diff.c and its diff transformers
  * (e.g. diffcore-rename, diffcore-pickaxe).  Never include this header
  * in anything else.
@@ -22,8 +25,6 @@
 
 #define MINIMUM_BREAK_SIZE 400 /* do not break a file smaller than this */
 
-struct userdiff_driver;
-
 struct diff_filespec {
unsigned char sha1[20];
char *path;
diff --git i/object.h w/object.h
index 5e8d8ee..e61b290 100644
--- i/object.h
+++ w/object.h
@@ -1,6 +1,8 @@
 #ifndef OBJECT_H
 #define OBJECT_H
 
+#include cache.h
+
 struct object_list {
struct object *item;
struct object_list *next;
diff --git i/tree-walk.h w/tree-walk.h
index ae7fb3a..d7612cf 100644
--- i/tree-walk.h
+++ w/tree-walk.h
@@ -1,6 +1,8 @@
 #ifndef TREE_WALK_H
 #define TREE_WALK_H
 
+struct strbuf;
+
 struct name_entry {
const unsigned char *sha1;
const char *path;
diff --git i/tree.h w/tree.h
index d84ac63..ef84153 100644
--- i/tree.h
+++ w/tree.h
@@ -3,6 +3,9 @@
 
 #include object.h
 
+struct pathspec;
+
+
 extern const char *tree_type;
 
 struct tree {
--
To 

Re: [RFC PATCH v2 2/2] headers: include dependent headers

2014-09-07 Thread David Aguilar
On Sun, Sep 07, 2014 at 12:49:18PM -0700, Jonathan Nieder wrote:
 David Aguilar wrote:
 
  Add dependent headers so that including a header does not
  require including additional headers.
 
 I agree with this goal, modulo the compat-util.h caveat.  Thanks
 for working on it.
 
 [...]
  --- a/archive.h
  +++ b/archive.h
  @@ -1,6 +1,7 @@
   #ifndef ARCHIVE_H
   #define ARCHIVE_H
   
  +#include cache.h
   #include pathspec.h
   
   struct archiver_args {
 
 I'm less happy about the way of achieving that goal.  Here's an
 alternative.  Advantages:
 
  * (fully expanded) headers stay small
 
  * fewer other headers included as a side-effect of including one
header, so callers are more likely to remember to #include the
headers defining things they need (which makes later refactoring
easier)
 
  * circular header dependencies are harder to produce
 
 If this seems like a good direction to go in, I can finish the patch
 later today

Yes, please, that would be sweet.

Would you mind squashing in your sug to patch 1/2 as well when resending?
It seems like a nice improvement all around.

RE: pre-compiled headers -- that might be a nice follow-up to
this series. I'm not very familiar with Windows so I don't know
if it would be doable on mingw, cygwin, and msvc et al. but if
it helps other platforms then it could be a nice feature.

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


Check out git-author

2014-09-07 Thread xmeng

Hi all,

I have been using git-blame to track who changed a line of code or who 
to blame for a line of code. It is easy to use. For example, for this 
particular line of code:


$ git blame -L 2235,2235 fs/ext4/mballoc.c
85556c9a (Wei Yongjun 2012-09-26 20:43:37 -0400 2235)   
meta_group_info[i] = kmem_cache_zalloc(cachep, GFP_KERNEL);


The problem with git-blame is that it only reports the last 
author/commit that changed the line, regardless of the magnitude of the 
change. Sometimes, the last author may only change a tiny part of the 
code and should not be blamed. I developed a built-in tool called 
git-author to address this problem. Git-author is designed to track 
the complete development history of a line. For the same line of code:


$ git author -c -L 2235,2235 fs/ext4/mballoc.c
   CURRENT LINE 2235:   meta_group_info[i] = 
kmem_cache_zalloc(cachep, GFP_KERNEL);
85556c9 Wei Yongjun :   meta_group_info[i] = 
kmem_cache_zalloc(cachep, GFP_KERNEL);
fb1813f Curt Wohlgemuth :   meta_group_info[i] = 
kmem_cache_alloc(cachep, GFP_KERNEL);
5f21b0e Frederic Bohe   :   meta_group_info[i] = kzalloc(len, 
GFP_KERNEL);
c9de560 Alex Tomas  :   meta_group_info[j] = 
kzalloc(len, GFP_KERNEL);


Git-author shows the complete development history of this line code. We 
can see Wei Yongjun only changed the line to call a different function 
(from kmem_cache_alloc to kmem_cache_zalloc). Wei yongjun is not 
responsible for the other part of the line. Curt Wohlgemuth changed 
the line to call a different function (from kzalloc to 
kmem_cache_alloc) and to use a different parameter (from len to 
cachep) and Frederic Bohe changed the line to use a different array 
index (from i to j).


Git-author should be useful to people who wants to see the complete 
history of lines of code.


If you are interested in git-author, you can check it out at 
https://github.com/mxz297/git/tree/git-author (please check out branch 
'git-author'). Also we have a paper describing more technical details 
about git-author in ICSM 2013 
(ftp://ftp.cs.wisc.edu/paradyn/papers/Meng13Authorship.pdf).


Let me know if you have any question, feedback, bug about git-author!


Thanks

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


Re: [PATCH v2] git svn: info: correctly handle absolute path args

2014-09-07 Thread brian m. carlson
On Sun, Sep 07, 2014 at 10:57:43AM +0200, Johannes Sixt wrote:
 Am 07.09.2014 10:06, schrieb Eric Wong:
   sub cmd_info {
  -   my $path = canonicalize_path(defined($_[0]) ? $_[0] : .);
  -   my $fullpath = canonicalize_path($cmd_dir_prefix . $path);
  +   my $path_arg = defined($_[0]) ? $_[0] : '.';
  +   my $path = $path_arg;
  +   if ($path =~ m!\A/!) {
 
 There must be a more portable way to check for an absolute path. Think
 of DOS-style paths...

You probably want File::Spec-file_name_is_absolute($path).  Either that
or always turn the path into absolute or relative form with
File::Spec-abs2rel or File::Spec-rel2abs, and then go from there.
-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187


signature.asc
Description: Digital signature


Re: Check out git-author

2014-09-07 Thread Jeff King
On Sun, Sep 07, 2014 at 06:05:13PM -0500, xmeng wrote:

 The problem with git-blame is that it only reports the last author/commit
 that changed the line, regardless of the magnitude of the change. Sometimes,
 the last author may only change a tiny part of the code and should not be
 blamed. I developed a built-in tool called git-author to address this
 problem. Git-author is designed to track the complete development history of
 a line. For the same line of code:
 
 $ git author -c -L 2235,2235 fs/ext4/mballoc.c
 [...]

Have you tried git log -L 2235,2235:fs/ext4/mballoc.c --
fs/ext4/mballoc.c? Can you compare your approach to that of log -L?

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