[PATCH] tree-walk: convert fill_tree_descriptor() to object_id

2017-08-12 Thread René Scharfe
All callers of fill_tree_descriptor() have been converted to object_id
already, so convert that function as well.  As a nice side-effect we get
rid of NULL checks in tree-diff.c, as fill_tree_descriptor() already
does them for us.

Signed-off-by: Rene Scharfe 
---
 Documentation/technical/api-tree-walking.txt |  6 +++---
 builtin/merge-tree.c | 10 +-
 builtin/reset.c  |  4 ++--
 notes.c  |  2 +-
 tree-diff.c  |  5 ++---
 tree-walk.c  |  9 +
 tree-walk.h  |  2 +-
 unpack-trees.c   |  6 +++---
 8 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/Documentation/technical/api-tree-walking.txt 
b/Documentation/technical/api-tree-walking.txt
index 14af37c3f1..a5334a472e 100644
--- a/Documentation/technical/api-tree-walking.txt
+++ b/Documentation/technical/api-tree-walking.txt
@@ -55,9 +55,9 @@ Initializing
 
 `fill_tree_descriptor`::
 
-   Initialize a `tree_desc` and decode its first entry given the sha1 of
-   a tree. Returns the `buffer` member if the sha1 is a valid tree
-   identifier and NULL otherwise.
+   Initialize a `tree_desc` and decode its first entry given the
+   object ID of a tree. Returns the `buffer` member if the sha1 is
+   a valid tree identifier and NULL otherwise.
 
 `setup_traverse_info`::
 
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index f12da292cf..6ea246a200 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -213,10 +213,10 @@ static void unresolved_directory(const struct 
traverse_info *info,
 
newbase = traverse_path(info, p);
 
-#define ENTRY_SHA1(e) (((e)->mode && S_ISDIR((e)->mode)) ? (e)->oid->hash : 
NULL)
-   buf0 = fill_tree_descriptor(t+0, ENTRY_SHA1(n + 0));
-   buf1 = fill_tree_descriptor(t+1, ENTRY_SHA1(n + 1));
-   buf2 = fill_tree_descriptor(t+2, ENTRY_SHA1(n + 2));
+#define ENTRY_OID(e) (((e)->mode && S_ISDIR((e)->mode)) ? (e)->oid : NULL)
+   buf0 = fill_tree_descriptor(t + 0, ENTRY_OID(n + 0));
+   buf1 = fill_tree_descriptor(t + 1, ENTRY_OID(n + 1));
+   buf2 = fill_tree_descriptor(t + 2, ENTRY_OID(n + 2));
 #undef ENTRY_SHA1
 
merge_trees(t, newbase);
@@ -352,7 +352,7 @@ static void *get_tree_descriptor(struct tree_desc *desc, 
const char *rev)
 
if (get_oid(rev, &oid))
die("unknown rev %s", rev);
-   buf = fill_tree_descriptor(desc, oid.hash);
+   buf = fill_tree_descriptor(desc, &oid);
if (!buf)
die("%s is not a tree", rev);
return buf;
diff --git a/builtin/reset.c b/builtin/reset.c
index 046403ed68..4a02d74073 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -75,13 +75,13 @@ static int reset_index(const struct object_id *oid, int 
reset_type, int quiet)
struct object_id head_oid;
if (get_oid("HEAD", &head_oid))
return error(_("You do not have a valid HEAD."));
-   if (!fill_tree_descriptor(desc, head_oid.hash))
+   if (!fill_tree_descriptor(desc, &head_oid))
return error(_("Failed to find tree of HEAD."));
nr++;
opts.fn = twoway_merge;
}
 
-   if (!fill_tree_descriptor(desc + nr - 1, oid->hash))
+   if (!fill_tree_descriptor(desc + nr - 1, oid))
return error(_("Failed to find tree of %s."), oid_to_hex(oid));
if (unpack_trees(nr, desc, &opts))
return -1;
diff --git a/notes.c b/notes.c
index 503754d79e..f090c88363 100644
--- a/notes.c
+++ b/notes.c
@@ -425,7 +425,7 @@ static void load_subtree(struct notes_tree *t, struct 
leaf_node *subtree,
unsigned char type;
struct leaf_node *l;
 
-   buf = fill_tree_descriptor(&desc, subtree->val_oid.hash);
+   buf = fill_tree_descriptor(&desc, &subtree->val_oid);
if (!buf)
die("Could not read %s for notes-index",
 oid_to_hex(&subtree->val_oid));
diff --git a/tree-diff.c b/tree-diff.c
index 2357f72899..4bb93155bc 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -421,9 +421,8 @@ static struct combine_diff_path *ll_diff_tree_paths(
 *   diff_tree_oid(parent, commit) )
 */
for (i = 0; i < nparent; ++i)
-   tptree[i] = fill_tree_descriptor(&tp[i],
-   parents_oid[i] ? parents_oid[i]->hash : NULL);
-   ttree = fill_tree_descriptor(&t, oid ? oid->hash : NULL);
+   tptree[i] = fill_tree_descriptor(&tp[i], parents_oid[i]);
+   ttree = fill_tree_descriptor(&t, oid);
 
/* Enable recursion indefinitely */
opt->pathspec.recursive = DIFF_OPT_TST(opt, RECURSIVE);
diff --git a/tree-walk.c b/tree-walk.c
index 6a42e402b0..c99309069a 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -78,15 +78,16 @@ int 

Re: [PATCH] tree-walk: convert fill_tree_descriptor() to object_id

2017-08-12 Thread Johannes Sixt

Am 12.08.2017 um 09:14 schrieb René Scharfe:

-   Initialize a `tree_desc` and decode its first entry given the sha1 of
-   a tree. Returns the `buffer` member if the sha1 is a valid tree
-   identifier and NULL otherwise.
+   Initialize a `tree_desc` and decode its first entry given the
+   object ID of a tree. Returns the `buffer` member if the sha1 is
+   a valid tree identifier and NULL otherwise.


There is another mention of "sha1" in the rewritten text. Intended or an 
oversight?



-#define ENTRY_SHA1(e) (((e)->mode && S_ISDIR((e)->mode)) ? (e)->oid->hash : 
NULL)
-   buf0 = fill_tree_descriptor(t+0, ENTRY_SHA1(n + 0));
-   buf1 = fill_tree_descriptor(t+1, ENTRY_SHA1(n + 1));
-   buf2 = fill_tree_descriptor(t+2, ENTRY_SHA1(n + 2));
+#define ENTRY_OID(e) (((e)->mode && S_ISDIR((e)->mode)) ? (e)->oid : NULL)
+   buf0 = fill_tree_descriptor(t + 0, ENTRY_OID(n + 0));
+   buf1 = fill_tree_descriptor(t + 1, ENTRY_OID(n + 1));
+   buf2 = fill_tree_descriptor(t + 2, ENTRY_OID(n + 2));
  #undef ENTRY_SHA1


This whould be #undef ENTRY_OID.

-- Hannes


description about necessary libs on INSTALL

2017-08-12 Thread Kazuki Tsunemi
Hello!

I have an idea about document.
I installed git with INSTALL. I executed 'make install' but got some
errors while building. I found necessary libs written in INSTALL after
all build errors have solved.
How about write about libs before install command ? I think it is better :)

---
Kazuki Tsunemi


[PATCH v2] tree-walk: convert fill_tree_descriptor() to object_id

2017-08-12 Thread René Scharfe
All callers of fill_tree_descriptor() have been converted to object_id
already, so convert that function as well.  As a nice side-effect we get
rid of NULL checks in tree-diff.c, as fill_tree_descriptor() already
does them for us.

Helped-by: Johannes Sixt 
Signed-off-by: Rene Scharfe 
---
Changes from v1: Don't mention sha1 in documentation anymore, #undef
ENTRY_OID.  Thanks for spotting, Johannes!

 Documentation/technical/api-tree-walking.txt |  6 +++---
 builtin/merge-tree.c | 12 ++--
 builtin/reset.c  |  4 ++--
 notes.c  |  2 +-
 tree-diff.c  |  5 ++---
 tree-walk.c  |  9 +
 tree-walk.h  |  2 +-
 unpack-trees.c   |  6 +++---
 8 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/Documentation/technical/api-tree-walking.txt 
b/Documentation/technical/api-tree-walking.txt
index 14af37c3f1..bde18622a8 100644
--- a/Documentation/technical/api-tree-walking.txt
+++ b/Documentation/technical/api-tree-walking.txt
@@ -55,9 +55,9 @@ Initializing
 
 `fill_tree_descriptor`::
 
-   Initialize a `tree_desc` and decode its first entry given the sha1 of
-   a tree. Returns the `buffer` member if the sha1 is a valid tree
-   identifier and NULL otherwise.
+   Initialize a `tree_desc` and decode its first entry given the
+   object ID of a tree. Returns the `buffer` member if the latter
+   is a valid tree identifier and NULL otherwise.
 
 `setup_traverse_info`::
 
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index f12da292cf..d01ddecf66 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -213,11 +213,11 @@ static void unresolved_directory(const struct 
traverse_info *info,
 
newbase = traverse_path(info, p);
 
-#define ENTRY_SHA1(e) (((e)->mode && S_ISDIR((e)->mode)) ? (e)->oid->hash : 
NULL)
-   buf0 = fill_tree_descriptor(t+0, ENTRY_SHA1(n + 0));
-   buf1 = fill_tree_descriptor(t+1, ENTRY_SHA1(n + 1));
-   buf2 = fill_tree_descriptor(t+2, ENTRY_SHA1(n + 2));
-#undef ENTRY_SHA1
+#define ENTRY_OID(e) (((e)->mode && S_ISDIR((e)->mode)) ? (e)->oid : NULL)
+   buf0 = fill_tree_descriptor(t + 0, ENTRY_OID(n + 0));
+   buf1 = fill_tree_descriptor(t + 1, ENTRY_OID(n + 1));
+   buf2 = fill_tree_descriptor(t + 2, ENTRY_OID(n + 2));
+#undef ENTRY_OID
 
merge_trees(t, newbase);
 
@@ -352,7 +352,7 @@ static void *get_tree_descriptor(struct tree_desc *desc, 
const char *rev)
 
if (get_oid(rev, &oid))
die("unknown rev %s", rev);
-   buf = fill_tree_descriptor(desc, oid.hash);
+   buf = fill_tree_descriptor(desc, &oid);
if (!buf)
die("%s is not a tree", rev);
return buf;
diff --git a/builtin/reset.c b/builtin/reset.c
index 046403ed68..4a02d74073 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -75,13 +75,13 @@ static int reset_index(const struct object_id *oid, int 
reset_type, int quiet)
struct object_id head_oid;
if (get_oid("HEAD", &head_oid))
return error(_("You do not have a valid HEAD."));
-   if (!fill_tree_descriptor(desc, head_oid.hash))
+   if (!fill_tree_descriptor(desc, &head_oid))
return error(_("Failed to find tree of HEAD."));
nr++;
opts.fn = twoway_merge;
}
 
-   if (!fill_tree_descriptor(desc + nr - 1, oid->hash))
+   if (!fill_tree_descriptor(desc + nr - 1, oid))
return error(_("Failed to find tree of %s."), oid_to_hex(oid));
if (unpack_trees(nr, desc, &opts))
return -1;
diff --git a/notes.c b/notes.c
index 503754d79e..f090c88363 100644
--- a/notes.c
+++ b/notes.c
@@ -425,7 +425,7 @@ static void load_subtree(struct notes_tree *t, struct 
leaf_node *subtree,
unsigned char type;
struct leaf_node *l;
 
-   buf = fill_tree_descriptor(&desc, subtree->val_oid.hash);
+   buf = fill_tree_descriptor(&desc, &subtree->val_oid);
if (!buf)
die("Could not read %s for notes-index",
 oid_to_hex(&subtree->val_oid));
diff --git a/tree-diff.c b/tree-diff.c
index 2357f72899..4bb93155bc 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -421,9 +421,8 @@ static struct combine_diff_path *ll_diff_tree_paths(
 *   diff_tree_oid(parent, commit) )
 */
for (i = 0; i < nparent; ++i)
-   tptree[i] = fill_tree_descriptor(&tp[i],
-   parents_oid[i] ? parents_oid[i]->hash : NULL);
-   ttree = fill_tree_descriptor(&t, oid ? oid->hash : NULL);
+   tptree[i] = fill_tree_descriptor(&tp[i], parents_oid[i]);
+   ttree = fill_tree_descriptor(&t, oid);
 
/* Enable recursion indefinitely */
opt->pathspec.recursive = DI

[PATCH 3/9] Convert unpack-objects to size_t

2017-08-12 Thread Martin Koegler
From: Martin Koegler 

Signed-off-by: Martin Koegler 
---
 builtin/unpack-objects.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index 001dd4b..0d8b6b3 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -31,7 +31,7 @@ static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT;
  */
 struct obj_buffer {
char *buffer;
-   unsigned long size;
+   size_t size;
 };
 
 static struct decoration obj_decorate;
@@ -41,7 +41,7 @@ static struct obj_buffer *lookup_object_buffer(struct object 
*base)
return lookup_decoration(&obj_decorate, base);
 }
 
-static void add_object_buffer(struct object *object, char *buffer, unsigned 
long size)
+static void add_object_buffer(struct object *object, char *buffer, size_t size)
 {
struct obj_buffer *obj;
obj = xcalloc(1, sizeof(struct obj_buffer));
@@ -93,7 +93,7 @@ static void use(int bytes)
die(_("pack exceeds maximum allowed size"));
 }
 
-static void *get_data(unsigned long size)
+static void *get_data(size_t size)
 {
git_zstream stream;
void *buf = xmallocz(size);
@@ -130,7 +130,7 @@ struct delta_info {
struct object_id base_oid;
unsigned nr;
off_t base_offset;
-   unsigned long size;
+   size_t size;
void *delta;
struct delta_info *next;
 };
@@ -139,7 +139,7 @@ static struct delta_info *delta_list;
 
 static void add_delta_to_list(unsigned nr, const struct object_id *base_oid,
  off_t base_offset,
- void *delta, unsigned long size)
+ void *delta, size_t size)
 {
struct delta_info *info = xmalloc(sizeof(*info));
 
@@ -226,7 +226,7 @@ static void write_rest(void)
 }
 
 static void added_object(unsigned nr, enum object_type type,
-void *data, unsigned long size);
+void *data, size_t size);
 
 /*
  * Write out nr-th object from the list, now we know the contents
@@ -234,7 +234,7 @@ static void added_object(unsigned nr, enum object_type type,
  * to be checked at the end.
  */
 static void write_object(unsigned nr, enum object_type type,
-void *buf, unsigned long size)
+void *buf, size_t size)
 {
if (!strict) {
if (write_sha1_file(buf, size, typename(type), 
obj_list[nr].oid.hash) < 0)
@@ -291,7 +291,7 @@ static void resolve_delta(unsigned nr, enum object_type 
type,
  * resolve all the deltified objects that are based on it.
  */
 static void added_object(unsigned nr, enum object_type type,
-void *data, unsigned long size)
+void *data, size_t size)
 {
struct delta_info **p = &delta_list;
struct delta_info *info;
@@ -310,7 +310,7 @@ static void added_object(unsigned nr, enum object_type type,
}
 }
 
-static void unpack_non_delta_entry(enum object_type type, unsigned long size,
+static void unpack_non_delta_entry(enum object_type type, size_t size,
   unsigned nr)
 {
void *buf = get_data(size);
@@ -436,7 +436,7 @@ static void unpack_one(unsigned nr)
 {
unsigned shift;
unsigned char *pack;
-   unsigned long size, c;
+   size_t size, c;
enum object_type type;
 
obj_list[nr].offset = consumed_bytes;
-- 
2.1.4



[PATCH] Add overflow check to get_delta_hdr_size

2017-08-12 Thread Martin Koegler
From: Martin Koegler 

Signed-off-by: Martin Koegler 
---
Applies on top of my size_t series

I'm not sure, if die or error is better.

 delta.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/delta.h b/delta.h
index 2df0f55..18a4983 100644
--- a/delta.h
+++ b/delta.h
@@ -96,6 +96,11 @@ static inline size_t get_delta_hdr_size(const unsigned char 
**datap,
cmd = *data++;
size |= (cmd & 0x7f) << i;
i += 7;
+   if (bitsizeof(size_t) <= i) {
+   error("too large object size");
+   size = 0;
+   break;
+   }
} while (cmd & 0x80 && data < top);
*datap = data;
return size;
-- 
2.1.4



[PATCH 4/9] Convert archive functions to size_t

2017-08-12 Thread Martin Koegler
From: Martin Koegler 

---
 archive-tar.c | 16 
 archive-zip.c | 22 +++---
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/archive-tar.c b/archive-tar.c
index 719673d..ee56b2b 100644
--- a/archive-tar.c
+++ b/archive-tar.c
@@ -12,7 +12,7 @@
 #define BLOCKSIZE  (RECORDSIZE * 20)
 
 static char block[BLOCKSIZE];
-static unsigned long offset;
+static size_t offset;
 
 static int tar_umask = 002;
 
@@ -50,12 +50,12 @@ static void write_if_needed(void)
  * queues up writes, so that all our write(2) calls write exactly one
  * full block; pads writes to RECORDSIZE
  */
-static void do_write_blocked(const void *data, unsigned long size)
+static void do_write_blocked(const void *data, size_t size)
 {
const char *buf = data;
 
if (offset) {
-   unsigned long chunk = BLOCKSIZE - offset;
+   size_t chunk = BLOCKSIZE - offset;
if (size < chunk)
chunk = size;
memcpy(block + offset, buf, chunk);
@@ -77,7 +77,7 @@ static void do_write_blocked(const void *data, unsigned long 
size)
 
 static void finish_record(void)
 {
-   unsigned long tail;
+   size_t tail;
tail = offset % RECORDSIZE;
if (tail)  {
memset(block + offset, 0, RECORDSIZE - tail);
@@ -86,7 +86,7 @@ static void finish_record(void)
write_if_needed();
 }
 
-static void write_blocked(const void *data, unsigned long size)
+static void write_blocked(const void *data, size_t size)
 {
do_write_blocked(data, size);
finish_record();
@@ -198,10 +198,10 @@ static size_t get_path_prefix(const char *path, size_t 
pathlen, size_t maxlen)
 
 static void prepare_header(struct archiver_args *args,
   struct ustar_header *header,
-  unsigned int mode, unsigned long size)
+  unsigned int mode, size_t size)
 {
xsnprintf(header->mode, sizeof(header->mode), "%07o", mode & 0);
-   xsnprintf(header->size, sizeof(header->size), "%011lo", S_ISREG(mode) ? 
size : 0);
+   xsnprintf(header->size, sizeof(header->size), "%011lo", S_ISREG(mode) ? 
(unsigned long)size : 0);
xsnprintf(header->mtime, sizeof(header->mtime), "%011lo", (unsigned 
long) args->time);
 
xsnprintf(header->uid, sizeof(header->uid), "%07o", 0);
@@ -219,7 +219,7 @@ static void prepare_header(struct archiver_args *args,
 
 static void write_extended_header(struct archiver_args *args,
  const unsigned char *sha1,
- const void *buffer, unsigned long size)
+ const void *buffer, size_t size)
 {
struct ustar_header header;
unsigned int mode;
diff --git a/archive-zip.c b/archive-zip.c
index 4492d64..3a54d80 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -186,12 +186,12 @@ static uint32_t clamp32(uintmax_t n)
return (n < max) ? n : max;
 }
 
-static void *zlib_deflate_raw(void *data, unsigned long size,
+static void *zlib_deflate_raw(void *data, size_t size,
  int compression_level,
- unsigned long *compressed_size)
+ size_t *compressed_size)
 {
git_zstream stream;
-   unsigned long maxsize;
+   size_t maxsize;
void *buffer;
int result;
 
@@ -219,9 +219,9 @@ static void *zlib_deflate_raw(void *data, unsigned long 
size,
return buffer;
 }
 
-static void write_zip_data_desc(unsigned long size,
-   unsigned long compressed_size,
-   unsigned long crc)
+static void write_zip_data_desc(size_t size,
+   size_t compressed_size,
+   uint32_t crc)
 {
if (size >= 0x || compressed_size >= 0x) {
struct zip64_data_desc trailer;
@@ -243,9 +243,9 @@ static void write_zip_data_desc(unsigned long size,
 }
 
 static void set_zip_header_data_desc(struct zip_local_header *header,
-unsigned long size,
-unsigned long compressed_size,
-unsigned long crc)
+size_t size,
+size_t compressed_size,
+uint32_t crc)
 {
copy_le32(header->crc32, crc);
copy_le32(header->compressed_size, compressed_size);
@@ -287,8 +287,8 @@ static int write_zip_entry(struct archiver_args *args,
size_t header_extra_size = ZIP_EXTRA_MTIME_SIZE;
int need_zip64_extra = 0;
unsigned long attr2;
-   unsigned long compressed_size;
-   unsigned long crc;
+   size_t compressed_size;
+   uint32_t crc;
int method;
unsigned char *out;
void *deflated = NULL;
-- 
2.1.4



[PATCH 5/9] Convert various things to size_t

2017-08-12 Thread Martin Koegler
From: Martin Koegler 

---
 bisect.c| 2 +-
 blame.c | 2 +-
 builtin/fmt-merge-msg.c | 2 +-
 builtin/mktag.c | 2 +-
 dir.c   | 4 ++--
 dir.h   | 2 +-
 6 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/bisect.c b/bisect.c
index 2549eaf..0580c82 100644
--- a/bisect.c
+++ b/bisect.c
@@ -131,7 +131,7 @@ static void show_list(const char *debug, int counted, int 
nr,
struct commit *commit = p->item;
unsigned flags = commit->object.flags;
enum object_type type;
-   unsigned long size;
+   size_t size;
char *buf = read_sha1_file(commit->object.sha1, &type, &size);
const char *subject_start;
int subject_len;
diff --git a/blame.c b/blame.c
index 739a280..f628b42 100644
--- a/blame.c
+++ b/blame.c
@@ -1621,7 +1621,7 @@ static const char *get_next_line(const char *start, const 
char *end)
 static int prepare_lines(struct blame_scoreboard *sb)
 {
const char *buf = sb->final_buf;
-   unsigned long len = sb->final_buf_size;
+   size_t len = sb->final_buf_size;
const char *end = buf + len;
const char *p;
int *lineno;
diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c
index 61ab796..3faf100 100644
--- a/builtin/fmt-merge-msg.c
+++ b/builtin/fmt-merge-msg.c
@@ -464,7 +464,7 @@ static void fmt_merge_msg_title(struct strbuf *out,
 static void fmt_tag_signature(struct strbuf *tagbuf,
  struct strbuf *sig,
  const char *buf,
- unsigned long len)
+ size_t len)
 {
const char *tag_body = strstr(buf, "\n\n");
if (tag_body) {
diff --git a/builtin/mktag.c b/builtin/mktag.c
index 0663106..ff919a7 100644
--- a/builtin/mktag.c
+++ b/builtin/mktag.c
@@ -34,7 +34,7 @@ static int verify_object(const unsigned char *sha1, const 
char *expected_type)
return ret;
 }
 
-static int verify_tag(char *buffer, unsigned long size)
+static int verify_tag(char *buffer, size_t size)
 {
int typelen;
char type[20];
diff --git a/dir.c b/dir.c
index f161c26..0c7c767 100644
--- a/dir.c
+++ b/dir.c
@@ -180,7 +180,7 @@ static size_t common_prefix_len(const struct pathspec 
*pathspec)
  */
 char *common_prefix(const struct pathspec *pathspec)
 {
-   unsigned long len = common_prefix_len(pathspec);
+   size_t len = common_prefix_len(pathspec);
 
return len ? xmemdupz(pathspec->items[0].match, len) : NULL;
 }
@@ -2673,7 +2673,7 @@ static void load_sha1_stat(struct sha1_stat *sha1_stat,
sha1_stat->valid = 1;
 }
 
-struct untracked_cache *read_untracked_extension(const void *data, unsigned 
long sz)
+struct untracked_cache *read_untracked_extension(const void *data, size_t sz)
 {
struct untracked_cache *uc;
struct read_data rd;
diff --git a/dir.h b/dir.h
index e371705..709c72c 100644
--- a/dir.h
+++ b/dir.h
@@ -349,7 +349,7 @@ void untracked_cache_remove_from_index(struct index_state 
*, const char *);
 void untracked_cache_add_to_index(struct index_state *, const char *);
 
 void free_untracked_cache(struct untracked_cache *);
-struct untracked_cache *read_untracked_extension(const void *data, unsigned 
long sz);
+struct untracked_cache *read_untracked_extension(const void *data, size_t sz);
 void write_untracked_extension(struct strbuf *out, struct untracked_cache 
*untracked);
 void add_untracked_cache(struct index_state *istate);
 void remove_untracked_cache(struct index_state *istate);
-- 
2.1.4



[PATCH 7/9] Convert ref-filter to size_t

2017-08-12 Thread Martin Koegler
From: Martin Koegler 

Signed-off-by: Martin Koegler 
---
 ref-filter.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/ref-filter.c b/ref-filter.c
index 5c903a5..30f249c 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -724,7 +724,7 @@ static int grab_objectname(const char *name, const unsigned 
char *sha1,
 }
 
 /* See grab_values */
-static void grab_common_values(struct atom_value *val, int deref, struct 
object *obj, void *buf, unsigned long sz)
+static void grab_common_values(struct atom_value *val, int deref, struct 
object *obj, void *buf, size_t sz)
 {
int i;
 
@@ -739,7 +739,7 @@ static void grab_common_values(struct atom_value *val, int 
deref, struct object
v->s = typename(obj->type);
else if (!strcmp(name, "objectsize")) {
v->value = sz;
-   v->s = xstrfmt("%lu", sz);
+   v->s = xstrfmt("%" PRIuMAX, (uintmax_t)sz);
}
else if (deref)
grab_objectname(name, obj->oid.hash, v, &used_atom[i]);
@@ -747,7 +747,7 @@ static void grab_common_values(struct atom_value *val, int 
deref, struct object
 }
 
 /* See grab_values */
-static void grab_tag_values(struct atom_value *val, int deref, struct object 
*obj, void *buf, unsigned long sz)
+static void grab_tag_values(struct atom_value *val, int deref, struct object 
*obj, void *buf, size_t sz)
 {
int i;
struct tag *tag = (struct tag *) obj;
@@ -769,7 +769,7 @@ static void grab_tag_values(struct atom_value *val, int 
deref, struct object *ob
 }
 
 /* See grab_values */
-static void grab_commit_values(struct atom_value *val, int deref, struct 
object *obj, void *buf, unsigned long sz)
+static void grab_commit_values(struct atom_value *val, int deref, struct 
object *obj, void *buf, size_t sz)
 {
int i;
struct commit *commit = (struct commit *) obj;
@@ -786,7 +786,7 @@ static void grab_commit_values(struct atom_value *val, int 
deref, struct object
}
else if (!strcmp(name, "numparent")) {
v->value = commit_list_count(commit->parents);
-   v->s = xstrfmt("%lu", (unsigned long)v->value);
+   v->s = xstrfmt("%" PRIuMAX, (uintmax_t)v->value);
}
else if (!strcmp(name, "parent")) {
struct commit_list *parents;
@@ -802,7 +802,7 @@ static void grab_commit_values(struct atom_value *val, int 
deref, struct object
}
 }
 
-static const char *find_wholine(const char *who, int wholen, const char *buf, 
unsigned long sz)
+static const char *find_wholine(const char *who, int wholen, const char *buf, 
size_t sz)
 {
const char *eol;
while (*buf) {
@@ -848,7 +848,7 @@ static const char *copy_email(const char *buf)
return xmemdupz(email, eoemail + 1 - email);
 }
 
-static char *copy_subject(const char *buf, unsigned long len)
+static char *copy_subject(const char *buf, size_t len)
 {
char *r = xmemdupz(buf, len);
int i;
@@ -898,7 +898,7 @@ static void grab_date(const char *buf, struct atom_value 
*v, const char *atomnam
 }
 
 /* See grab_values */
-static void grab_person(const char *who, struct atom_value *val, int deref, 
struct object *obj, void *buf, unsigned long sz)
+static void grab_person(const char *who, struct atom_value *val, int deref, 
struct object *obj, void *buf, size_t sz)
 {
int i;
int wholen = strlen(who);
@@ -957,11 +957,11 @@ static void grab_person(const char *who, struct 
atom_value *val, int deref, stru
}
 }
 
-static void find_subpos(const char *buf, unsigned long sz,
-   const char **sub, unsigned long *sublen,
-   const char **body, unsigned long *bodylen,
-   unsigned long *nonsiglen,
-   const char **sig, unsigned long *siglen)
+static void find_subpos(const char *buf, size_t sz,
+   const char **sub, size_t *sublen,
+   const char **body, size_t *bodylen,
+   size_t *nonsiglen,
+   const char **sig, size_t *siglen)
 {
const char *eol;
/* skip past header until we hit empty line */
@@ -1005,7 +1005,7 @@ static void find_subpos(const char *buf, unsigned long sz,
  * If 'lines' is greater than 0, append that many lines from the given
  * 'buf' of length 'size' to the given strbuf.
  */
-static void append_lines(struct strbuf *out, const char *buf, unsigned long 
size, int lines)
+static void append_lines(struct strbuf *out, const char *buf, size_t size, int 
lines)
 {
int i;
const char *sp, *eol;
@@ -1026,11 +1026,11 @@ static void append_lines(struct strbuf *out, const char 
*buf, unsigned long size
 }
 
 /* See grab_values */
-static void grab_sub_body_contents(struct atom_value *val, int de

[PATCH 8/9] Convert tree-walk to size_t

2017-08-12 Thread Martin Koegler
From: Martin Koegler 

Signed-off-by: Martin Koegler 
---
 tree-walk.c | 17 +
 tree-walk.h |  4 ++--
 tree.h  |  2 +-
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/tree-walk.c b/tree-walk.c
index 7c9f9e3..a7d8b2a 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -22,10 +22,11 @@ static const char *get_mode(const char *str, unsigned int 
*modep)
return str;
 }
 
-static int decode_tree_entry(struct tree_desc *desc, const char *buf, unsigned 
long size, struct strbuf *err)
+static int decode_tree_entry(struct tree_desc *desc, const char *buf, size_t 
size, struct strbuf *err)
 {
const char *path;
-   unsigned int mode, len;
+   unsigned int mode;
+   size_t len;
 
if (size < 23 || buf[size - 21]) {
strbuf_addstr(err, _("too-short tree object"));
@@ -51,7 +52,7 @@ static int decode_tree_entry(struct tree_desc *desc, const 
char *buf, unsigned l
return 0;
 }
 
-static int init_tree_desc_internal(struct tree_desc *desc, const void *buffer, 
unsigned long size, struct strbuf *err)
+static int init_tree_desc_internal(struct tree_desc *desc, const void *buffer, 
size_t size, struct strbuf *err)
 {
desc->buffer = buffer;
desc->size = size;
@@ -60,7 +61,7 @@ static int init_tree_desc_internal(struct tree_desc *desc, 
const void *buffer, u
return 0;
 }
 
-void init_tree_desc(struct tree_desc *desc, const void *buffer, unsigned long 
size)
+void init_tree_desc(struct tree_desc *desc, const void *buffer, size_t size)
 {
struct strbuf err = STRBUF_INIT;
if (init_tree_desc_internal(desc, buffer, size, &err))
@@ -68,7 +69,7 @@ void init_tree_desc(struct tree_desc *desc, const void 
*buffer, unsigned long si
strbuf_release(&err);
 }
 
-int init_tree_desc_gently(struct tree_desc *desc, const void *buffer, unsigned 
long size)
+int init_tree_desc_gently(struct tree_desc *desc, const void *buffer, size_t 
size)
 {
struct strbuf err = STRBUF_INIT;
int result = init_tree_desc_internal(desc, buffer, size, &err);
@@ -106,8 +107,8 @@ static int update_tree_entry_internal(struct tree_desc 
*desc, struct strbuf *err
 {
const void *buf = desc->buffer;
const unsigned char *end = desc->entry.oid->hash + 20;
-   unsigned long size = desc->size;
-   unsigned long len = end - (const unsigned char *)buf;
+   size_t size = desc->size;
+   size_t len = end - (const unsigned char *)buf;
 
if (size < len)
die(_("too-short tree file"));
@@ -487,7 +488,7 @@ int traverse_trees(int n, struct tree_desc *t, struct 
traverse_info *info)
 
 struct dir_state {
void *tree;
-   unsigned long size;
+   size_t size;
unsigned char sha1[20];
 };
 
diff --git a/tree-walk.h b/tree-walk.h
index 68bb78b..9160cc2 100644
--- a/tree-walk.h
+++ b/tree-walk.h
@@ -32,8 +32,8 @@ static inline int tree_entry_len(const struct name_entry *ne)
 
 void update_tree_entry(struct tree_desc *);
 int update_tree_entry_gently(struct tree_desc *);
-void init_tree_desc(struct tree_desc *desc, const void *buf, unsigned long 
size);
-int init_tree_desc_gently(struct tree_desc *desc, const void *buf, unsigned 
long size);
+void init_tree_desc(struct tree_desc *desc, const void *buf, size_t size);
+int init_tree_desc_gently(struct tree_desc *desc, const void *buf, size_t 
size);
 
 /*
  * Helper function that does both tree_entry_extract() and update_tree_entry()
diff --git a/tree.h b/tree.h
index 1dac7fc..69b9233 100644
--- a/tree.h
+++ b/tree.h
@@ -9,7 +9,7 @@ struct strbuf;
 struct tree {
struct object object;
void *buffer;
-   unsigned long size;
+   size_t size;
 };
 
 struct tree *lookup_tree(const struct object_id *oid);
-- 
2.1.4



[PATCH 2/9] Convert index-pack to size_t

2017-08-12 Thread Martin Koegler
From: Martin Koegler 

Signed-off-by: Martin Koegler 
---
 builtin/index-pack.c | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 7f3ccd0..bf2d728 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -435,7 +435,7 @@ static int is_delta_type(enum object_type type)
return (type == OBJ_REF_DELTA || type == OBJ_OFS_DELTA);
 }
 
-static void *unpack_entry_data(off_t offset, unsigned long size,
+static void *unpack_entry_data(off_t offset, size_t size,
   enum object_type type, unsigned char *sha1)
 {
static char fixed_buf[8192];
@@ -444,10 +444,10 @@ static void *unpack_entry_data(off_t offset, unsigned 
long size,
void *buf;
git_SHA_CTX c;
char hdr[32];
-   int hdrlen;
+   size_t hdrlen;
 
if (!is_delta_type(type)) {
-   hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", typename(type), 
size) + 1;
+   hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %" PRIuMAX, 
typename(type), (uintmax_t)size) + 1;
git_SHA1_Init(&c);
git_SHA1_Update(&c, hdr, hdrlen);
} else
@@ -489,7 +489,7 @@ static void *unpack_raw_entry(struct object_entry *obj,
  unsigned char *sha1)
 {
unsigned char *p;
-   unsigned long size, c;
+   size_t size, c;
off_t base_offset;
unsigned shift;
void *data;
@@ -551,11 +551,11 @@ static void *unpack_raw_entry(struct object_entry *obj,
 }
 
 static void *unpack_data(struct object_entry *obj,
-int (*consume)(const unsigned char *, unsigned long, 
void *),
+int (*consume)(const unsigned char *, size_t, void *),
 void *cb_data)
 {
off_t from = obj[0].idx.offset + obj[0].hdr_size;
-   off_t len = obj[1].idx.offset - from;
+   size_t len = obj[1].idx.offset - from;
unsigned char *data, *inbuf;
git_zstream stream;
int status;
@@ -728,10 +728,10 @@ struct compare_data {
struct object_entry *entry;
struct git_istream *st;
unsigned char *buf;
-   unsigned long buf_size;
+   size_t buf_size;
 };
 
-static int compare_objects(const unsigned char *buf, unsigned long size,
+static int compare_objects(const unsigned char *buf, size_t size,
   void *cb_data)
 {
struct compare_data *data = cb_data;
@@ -783,7 +783,7 @@ static int check_collison(struct object_entry *entry)
 }
 
 static void sha1_object(const void *data, struct object_entry *obj_entry,
-   unsigned long size, enum object_type type,
+   size_t size, enum object_type type,
const struct object_id *oid)
 {
void *new_data = NULL;
@@ -1311,11 +1311,11 @@ static int write_compressed(struct sha1file *f, void 
*in, unsigned int size)
 
 static struct object_entry *append_obj_to_pack(struct sha1file *f,
   const unsigned char *sha1, void *buf,
-  unsigned long size, enum object_type type)
+  size_t size, enum object_type type)
 {
struct object_entry *obj = &objects[nr_objects++];
unsigned char header[10];
-   unsigned long s = size;
+   size_t s = size;
int n = 0;
unsigned char c = (type << 4) | (s & 15);
s >>= 4;
@@ -1585,10 +1585,10 @@ static void show_pack_info(int stat_only)
chain_histogram[obj_stat[i].delta_depth - 1]++;
if (stat_only)
continue;
-   printf("%s %-6s %" PRIuMAX " %lu %" PRIuMAX,
+   printf("%s %-6s %" PRIuMAX " %" PRIuMAX " %" PRIuMAX,
   oid_to_hex(&obj->idx.oid),
   typename(obj->real_type), (uintmax_t)obj->size,
-  (unsigned long)(obj[1].idx.offset - obj->idx.offset),
+  (uintmax_t)(obj[1].idx.offset - obj->idx.offset),
   (uintmax_t)obj->idx.offset);
if (is_delta_type(obj->type)) {
struct object_entry *bobj = 
&objects[obj_stat[i].base_object_no];
-- 
2.1.4



[PATCH 6/9] Use size_t for config parsing

2017-08-12 Thread Martin Koegler
From: Martin Koegler 

Signed-off-by: Martin Koegler 
---
 builtin/pack-objects.c |  6 +++---
 config.c   | 27 ++-
 config.h   |  1 +
 3 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index f8db283..0086da7 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -2450,7 +2450,7 @@ static int git_pack_config(const char *k, const char *v, 
void *cb)
return 0;
}
if (!strcmp(k, "pack.windowmemory")) {
-   window_memory_limit = git_config_ulong(k, v);
+   window_memory_limit = git_config_size_t(k, v);
return 0;
}
if (!strcmp(k, "pack.depth")) {
@@ -2458,11 +2458,11 @@ static int git_pack_config(const char *k, const char 
*v, void *cb)
return 0;
}
if (!strcmp(k, "pack.deltacachesize")) {
-   max_delta_cache_size = git_config_int(k, v);
+   max_delta_cache_size = git_config_size_t(k, v);
return 0;
}
if (!strcmp(k, "pack.deltacachelimit")) {
-   cache_max_small_delta_size = git_config_int(k, v);
+   cache_max_small_delta_size = git_config_size_t(k, v);
return 0;
}
if (!strcmp(k, "pack.writebitmaphashcache")) {
diff --git a/config.c b/config.c
index 831cf8b..444b1d1 100644
--- a/config.c
+++ b/config.c
@@ -863,6 +863,15 @@ static int git_parse_ssize_t(const char *value, ssize_t 
*ret)
return 1;
 }
 
+static int git_parse_size_t(const char *value, size_t *ret)
+{
+   uintmax_t tmp;
+   if (!git_parse_unsigned(value, &tmp, 
maximum_signed_value_of_type(size_t)))
+   return 0;
+   *ret = tmp;
+   return 1;
+}
+
 NORETURN
 static void die_bad_number(const char *name, const char *value)
 {
@@ -929,6 +938,14 @@ ssize_t git_config_ssize_t(const char *name, const char 
*value)
return ret;
 }
 
+size_t git_config_size_t(const char *name, const char *value)
+{
+   size_t ret;
+   if (!git_parse_size_t(value, &ret))
+   die_bad_number(name, value);
+   return ret;
+}
+
 int git_parse_maybe_bool(const char *value)
 {
if (!value)
@@ -1105,7 +1122,7 @@ static int git_default_core_config(const char *var, const 
char *value)
 
if (!strcmp(var, "core.packedgitwindowsize")) {
int pgsz_x2 = getpagesize() * 2;
-   packed_git_window_size = git_config_ulong(var, value);
+   packed_git_window_size = git_config_size_t(var, value);
 
/* This value must be multiple of (pagesize * 2) */
packed_git_window_size /= pgsz_x2;
@@ -1116,17 +1133,17 @@ static int git_default_core_config(const char *var, 
const char *value)
}
 
if (!strcmp(var, "core.bigfilethreshold")) {
-   big_file_threshold = git_config_ulong(var, value);
+   big_file_threshold = git_config_size_t(var, value);
return 0;
}
 
if (!strcmp(var, "core.packedgitlimit")) {
-   packed_git_limit = git_config_ulong(var, value);
+   packed_git_limit = git_config_size_t(var, value);
return 0;
}
 
if (!strcmp(var, "core.deltabasecachelimit")) {
-   delta_base_cache_limit = git_config_ulong(var, value);
+   delta_base_cache_limit = git_config_size_t(var, value);
return 0;
}
 
@@ -1360,7 +1377,7 @@ int git_default_config(const char *var, const char 
*value, void *dummy)
}
 
if (!strcmp(var, "pack.packsizelimit")) {
-   pack_size_limit_cfg = git_config_ulong(var, value);
+   pack_size_limit_cfg = git_config_size_t(var, value);
return 0;
}
 
diff --git a/config.h b/config.h
index fb76729..c264ee8 100644
--- a/config.h
+++ b/config.h
@@ -54,6 +54,7 @@ extern int git_config_int(const char *, const char *);
 extern int64_t git_config_int64(const char *, const char *);
 extern unsigned long git_config_ulong(const char *, const char *);
 extern ssize_t git_config_ssize_t(const char *, const char *);
+extern size_t git_config_size_t(const char *, const char *);
 extern int git_config_bool_or_int(const char *, const char *, int *);
 extern int git_config_bool(const char *, const char *);
 extern int git_config_maybe_bool(const char *, const char *);
-- 
2.1.4



[PATCH 9/9] Convert xdiff-interface to size_t

2017-08-12 Thread Martin Koegler
From: Martin Koegler 

Signed-off-by: Martin Koegler 
---
 combine-diff.c |  2 +-
 diff.c | 28 ++--
 diffcore-pickaxe.c |  4 ++--
 xdiff-interface.c  |  6 +++---
 xdiff-interface.h  |  6 +++---
 5 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/combine-diff.c b/combine-diff.c
index acf39ec..ad5d177 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -343,7 +343,7 @@ struct combine_diff_state {
struct sline *lost_bucket;
 };
 
-static void consume_line(void *state_, char *line, unsigned long len)
+static void consume_line(void *state_, char *line, size_t len)
 {
struct combine_diff_state *state = state_;
if (5 < len && !memcmp("@@ -", line, 4)) {
diff --git a/diff.c b/diff.c
index dd6ff0a..1f56205 100644
--- a/diff.c
+++ b/diff.c
@@ -464,7 +464,7 @@ static struct diff_tempfile {
struct tempfile tempfile;
 } diff_temp[2];
 
-typedef unsigned long (*sane_truncate_fn)(char *line, unsigned long len);
+typedef size_t (*sane_truncate_fn)(char *line, size_t len);
 
 struct emit_callback {
int color_diff;
@@ -519,7 +519,7 @@ static int fill_mmfile(mmfile_t *mf, struct diff_filespec 
*one)
 }
 
 /* like fill_mmfile, but only for size, so we can avoid retrieving blob */
-static unsigned long diff_filespec_size(struct diff_filespec *one)
+static size_t diff_filespec_size(struct diff_filespec *one)
 {
if (!DIFF_FILE_VALID(one))
return 0;
@@ -1522,7 +1522,7 @@ struct diff_words_buffer {
int orig_nr, orig_alloc;
 };
 
-static void diff_words_append(char *line, unsigned long len,
+static void diff_words_append(char *line, size_t len,
struct diff_words_buffer *buffer)
 {
ALLOC_GROW(buffer->text.ptr, buffer->text.size + len, buffer->alloc);
@@ -1651,7 +1651,7 @@ static int color_words_output_graph_prefix(struct 
diff_words_data *diff_words)
}
 }
 
-static void fn_out_diff_words_aux(void *priv, char *line, unsigned long len)
+static void fn_out_diff_words_aux(void *priv, char *line, size_t len)
 {
struct diff_words_data *diff_words = priv;
struct diff_words_style *style = diff_words->style;
@@ -1962,10 +1962,10 @@ const char *diff_line_prefix(struct diff_options *opt)
return msgbuf->buf;
 }
 
-static unsigned long sane_truncate_line(struct emit_callback *ecb, char *line, 
unsigned long len)
+static size_t sane_truncate_line(struct emit_callback *ecb, char *line, size_t 
len)
 {
const char *cp;
-   unsigned long allot;
+   size_t allot;
size_t l = len;
 
if (ecb->truncate)
@@ -1995,7 +1995,7 @@ static void find_lno(const char *line, struct 
emit_callback *ecbdata)
ecbdata->lno_in_postimage = strtol(p + 1, NULL, 10);
 }
 
-static void fn_out_consume(void *priv, char *line, unsigned long len)
+static void fn_out_consume(void *priv, char *line, size_t len)
 {
struct emit_callback *ecbdata = priv;
const char *reset = diff_get_color(ecbdata->color_diff, DIFF_RESET);
@@ -2199,7 +2199,7 @@ static struct diffstat_file *diffstat_add(struct 
diffstat_t *diffstat,
return x;
 }
 
-static void diffstat_consume(void *priv, char *line, unsigned long len)
+static void diffstat_consume(void *priv, char *line, size_t len)
 {
struct diffstat_t *diffstat = priv;
struct diffstat_file *x = diffstat->files[diffstat->nr - 1];
@@ -2854,7 +2854,7 @@ struct checkdiff_t {
unsigned status;
 };
 
-static int is_conflict_marker(const char *line, int marker_size, unsigned long 
len)
+static int is_conflict_marker(const char *line, int marker_size, size_t len)
 {
char firstchar;
int cnt;
@@ -2877,7 +2877,7 @@ static int is_conflict_marker(const char *line, int 
marker_size, unsigned long l
return 1;
 }
 
-static void checkdiff_consume(void *priv, char *line, unsigned long len)
+static void checkdiff_consume(void *priv, char *line, size_t len)
 {
struct checkdiff_t *data = priv;
int marker_size = data->conflict_marker_size;
@@ -3692,7 +3692,7 @@ void diff_free_filespec_data(struct diff_filespec *s)
 
 static void prep_temp_blob(const char *path, struct diff_tempfile *temp,
   void *blob,
-  unsigned long size,
+  size_t size,
   const struct object_id *oid,
   int mode)
 {
@@ -5301,7 +5301,7 @@ struct patch_id_t {
int patchlen;
 };
 
-static int remove_space(char *line, int len)
+static size_t remove_space(char *line, size_t len)
 {
int i;
char *dst = line;
@@ -5314,10 +5314,10 @@ static int remove_space(char *line, int len)
return dst - line;
 }
 
-static void patch_id_consume(void *priv, char *line, unsigned long len)
+static void patch_id_consume(void *priv, char *line, size_t len)
 {
struct patch_id_t *data = priv;
-   int new_len;
+   size_t new_len;
 
/* Ignore line numbers w

[PATCH 1/9] Convert pack-objects to size_t

2017-08-12 Thread Martin Koegler
From: Martin Koegler 

Signed-off-by: Martin Koegler 
---
 builtin/pack-objects.c | 48 
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index aa70f80..f8db283 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -56,7 +56,7 @@ static struct pack_idx_option pack_idx_opts;
 static const char *base_name;
 static int progress = 1;
 static int window = 10;
-static unsigned long pack_size_limit;
+static size_t pack_size_limit;
 static int depth = 50;
 static int delta_search_threads;
 static int pack_to_stdout;
@@ -72,11 +72,11 @@ static int use_bitmap_index = -1;
 static int write_bitmap_index;
 static uint16_t write_bitmap_options;
 
-static unsigned long delta_cache_size = 0;
-static unsigned long max_delta_cache_size = 256 * 1024 * 1024;
-static unsigned long cache_max_small_delta_size = 1000;
+static size_t delta_cache_size = 0;
+static size_t max_delta_cache_size = 256 * 1024 * 1024;
+static size_t cache_max_small_delta_size = 1000;
 
-static unsigned long window_memory_limit = 0;
+static size_t window_memory_limit = 0;
 
 /*
  * stats
@@ -124,11 +124,11 @@ static void *get_delta(struct object_entry *entry)
return delta_buf;
 }
 
-static unsigned long do_compress(void **pptr, unsigned long size)
+static size_t do_compress(void **pptr, size_t size)
 {
git_zstream stream;
void *in, *out;
-   unsigned long maxsize;
+   size_t maxsize;
 
git_deflate_init(&stream, pack_compression_level);
maxsize = git_deflate_bound(&stream, size);
@@ -149,13 +149,13 @@ static unsigned long do_compress(void **pptr, unsigned 
long size)
return stream.total_out;
 }
 
-static unsigned long write_large_blob_data(struct git_istream *st, struct 
sha1file *f,
+static size_t write_large_blob_data(struct git_istream *st, struct sha1file *f,
   const unsigned char *sha1)
 {
git_zstream stream;
unsigned char ibuf[1024 * 16];
unsigned char obuf[1024 * 16];
-   unsigned long olen = 0;
+   size_t olen = 0;
 
git_deflate_init(&stream, pack_compression_level);
 
@@ -196,7 +196,7 @@ static int check_pack_inflate(struct packed_git *p,
struct pack_window **w_curs,
off_t offset,
off_t len,
-   unsigned long expect)
+   size_t expect)
 {
git_zstream stream;
unsigned char fakebuf[4096], *in;
@@ -238,13 +238,13 @@ static void copy_pack_data(struct sha1file *f,
 }
 
 /* Return 0 if we will bust the pack-size limit */
-static unsigned long write_no_reuse_object(struct sha1file *f, struct 
object_entry *entry,
-  unsigned long limit, int 
usable_delta)
+static size_t write_no_reuse_object(struct sha1file *f, struct object_entry 
*entry,
+   size_t limit, int usable_delta)
 {
size_t size, datalen;
unsigned char header[MAX_PACK_OBJECT_HEADER],
  dheader[MAX_PACK_OBJECT_HEADER];
-   unsigned hdrlen;
+   size_t hdrlen;
enum object_type type;
void *buf;
struct git_istream *st = NULL;
@@ -350,17 +350,17 @@ static unsigned long write_no_reuse_object(struct 
sha1file *f, struct object_ent
 
 /* Return 0 if we will bust the pack-size limit */
 static off_t write_reuse_object(struct sha1file *f, struct object_entry *entry,
-   unsigned long limit, int usable_delta)
+   size_t limit, int usable_delta)
 {
struct packed_git *p = entry->in_pack;
struct pack_window *w_curs = NULL;
struct revindex_entry *revidx;
off_t offset;
enum object_type type = entry->type;
-   off_t datalen;
+   size_t datalen;
unsigned char header[MAX_PACK_OBJECT_HEADER],
  dheader[MAX_PACK_OBJECT_HEADER];
-   unsigned hdrlen;
+   size_t hdrlen;
 
if (entry->delta)
type = (allow_ofs_delta && entry->delta->idx.offset) ?
@@ -431,7 +431,7 @@ static off_t write_object(struct sha1file *f,
  struct object_entry *entry,
  off_t write_offset)
 {
-   unsigned long limit;
+   size_t limit;
off_t len;
int usable_delta, to_reuse;
 
@@ -1120,7 +1120,7 @@ struct pbase_tree_cache {
int ref;
int temporary;
void *tree_data;
-   unsigned long tree_size;
+   size_t tree_size;
 };
 
 static struct pbase_tree_cache *(pbase_tree_cache[256]);
@@ -1759,8 +1759,8 @@ struct unpacked {
unsigned depth;
 };
 
-static int delta_cacheable(unsigned long src_size, unsigned long trg_size,
-  unsigned long delta_size)
+static int delta_cacheable(size_t src_size, size_t trg_size,
+  size_t delta_size)
 {
if (max_delta_cach

Re: [PATCH v2 1/2] format-patch: have progress option while generating patches

2017-08-12 Thread Philip Oakley

From: "Junio C Hamano" 

Jeff King  writes:


On Thu, Aug 10, 2017 at 02:32:55PM -0400, Kevin Willford wrote:

@@ -1493,6 +1496,8 @@ int cmd_format_patch(int argc, const char **argv, 
const char *prefix)

 OPT_FILENAME(0, "signature-file", &signature_file,
 N_("add a signature from a file")),
 OPT__QUIET(&quiet, N_("don't print the patch filenames")),
+ OPT_BOOL(0, "progress", &show_progress,
+ N_("show progress while generating patches")),


Earlier I suggested allowing --progress="custom text" since this may be
driven as plumbing for other commands. But I don't think there's any
need to worry about it now. It can be added seamlessly later if we find
such a caller.

@@ -1752,8 +1757,12 @@ int cmd_format_patch(int argc, const char **argv, 
const char *prefix)

 start_number--;
 }
 rev.add_signoff = do_signoff;
+
+ if (show_progress)
+ progress = start_progress_delay(_("Generating patches"), total, 0, 1);


I don't really have an opinion on a 1 second delay versus 2. I thought
we used 2 pretty consistently, though grepping around I do see a couple
of 1's. It probably doesn't matter, but just a curiosity.


Yeah, I also thought 2-second was what we used by default.  Perhaps
we would want to bring others in line?


 Surely the choice should depend on the purpose of the delay. IIRC 
the 1 second between patches on the formal 'sent' time was simply to ensure 
the patches had the right sequence. Delays for warnings and progress have 
different purposes, so I think it's more about the purpose than 
standardising the time (along with expectations [least surprise] if other 
messages are displayed).

--
Philip 



Re: [PATCH 1/2] http: Fix handling of missing CURLPROTO_*

2017-08-12 Thread Tom G. Christensen

On 12/08/17 02:30, Junio C Hamano wrote:

This may make the code to _compile_, but is it sensible to let the
code build and be used by the end users without the "these protocols
are safe" filter, I wonder?



Git will display a warning at runtime if this is not available but 
perhaps this warning could be worded more strongly and/or make reference 
to CVE-2009-0037.


-tgc


Re: Would it make sense to add `--depth=0` feature?

2017-08-12 Thread Philip Oakley

From: "ankostis" 

Would it be feasible/sensical to support clone/fetch with --depth=0?
The point is to download the tags/commit objects but not the actual
trees and blobs,
creating a "ledger" acting as a promise for the remote'e repo content?

Is there some estimation of the effort required to do such thing?

Best,
 Kostis


I think that the desire is reasonable, but that it doesn't match the shallow 
clone idea. I think you are asking for a 'Narrow' clone where there is some 
form of exclusion of the blobs and trees that attach to the commit objects 
(at the various depths of commit graph walking).


There is some work on-going at the moment for various types of sparse 
download (look for "lazy objects" and "partial clone" on the list archive 
https://public-inbox.org/git/?q=) to see if you can help with ensuring that 
the methods will be useful to you.

(I'm interested too!)
--
Philip 



Re: [PATCH 1/9] Convert pack-objects to size_t

2017-08-12 Thread Torsten Bögershausen
Thanks for working on this - unfortunatly the patch does not apply on
git.git/master.

Which baseline did you use ?



Re: [PATCH] strbuf: clear errno before calling getdelim(3)

2017-08-12 Thread Simon Ruderich
On Fri, Aug 11, 2017 at 10:52:51AM +0200, René Scharfe wrote:
> Am 11.08.2017 um 09:50 schrieb Simon Ruderich:
>> On Thu, Aug 10, 2017 at 10:56:40PM +0200, René Scharfe wrote:
>>> getdelim(3) returns -1 at the end of the file and if it encounters an
>>> error, but sets errno only in the latter case.  Set errno to zero before
>>> calling it to avoid misdiagnosing an out-of-memory condition due to a
>>> left-over value from some other function call.
>>
>> getdelim(3p) doesn't explicitly forbid changing the errno on EOF:
>>
>>  If no characters were read, and the end-of-file indicator for
>>  the stream is set, or if the stream is at end-of-file, the
>>  end-of-file indicator for the stream shall be set and the
>>  function shall return −1. If an error occurs, the error
>>  indicator for the stream shall be set, and the function shall
>>  return −1 and set errno to indicate the error.
>
> [snip]
>
>> I don't think that it matters in practice, but the "most" correct
>> way to handle this would be to check if feof(3) is true to check
>> for the non-errno case.
>
> Only if errors at EOF are guaranteed to be impossible.  Imagine
> getdelim being able to read to the end and then failing to get memory
> for the final NUL.  Other scenarios may be possible.

Good point. Instead of feof(3), checking ferror(3) should handle
that properly. It's guaranteed to be set by getdelim for any
error.

For example like this (as replacement for the original patch):

diff --git i/strbuf.c w/strbuf.c
index 89d22e3b0..831be21ce 100644
--- i/strbuf.c
+++ w/strbuf.c
@@ -495,7 +495,7 @@ int strbuf_getwholeline(struct strbuf *sb, FILE *fp, int 
term)
 * memory and retry, but that's unlikely to help for a malloc small
 * enough to hold a single line of input, anyway.
 */
-   if (errno == ENOMEM)
+   if (ferror(fp) && errno == ENOMEM)
die("Out of memory, getdelim failed");
 
/*

An edge case is if the error indicator was already set before
calling getdelim() and the errno was already set to ENOMEM. This
could be fixed by checking ferror() before calling getdelim, but
I'm not sure if that's necessary:

diff --git i/strbuf.c w/strbuf.c
index 89d22e3b0..4d394bb91 100644
--- i/strbuf.c
+++ w/strbuf.c
@@ -468,7 +468,7 @@ int strbuf_getwholeline(struct strbuf *sb, FILE *fp, int 
term)
 {
ssize_t r;
 
-   if (feof(fp))
+   if (feof(fp) || ferror(fp))
return EOF;
 
strbuf_reset(sb);

Regards
Simon
-- 
+ Privatsphäre ist notwendig
+ Ich verwende GnuPG http://gnupg.org
+ Öffentlicher Schlüssel: 0x92FEFDB7E44C32F9


Re: [PATCH] strbuf: clear errno before calling getdelim(3)

2017-08-12 Thread René Scharfe
Am 12.08.2017 um 12:02 schrieb Simon Ruderich:
> On Fri, Aug 11, 2017 at 10:52:51AM +0200, René Scharfe wrote:
>> Am 11.08.2017 um 09:50 schrieb Simon Ruderich:
>>> On Thu, Aug 10, 2017 at 10:56:40PM +0200, René Scharfe wrote:
 getdelim(3) returns -1 at the end of the file and if it encounters an
 error, but sets errno only in the latter case.  Set errno to zero before
 calling it to avoid misdiagnosing an out-of-memory condition due to a
 left-over value from some other function call.
>>>
>>> getdelim(3p) doesn't explicitly forbid changing the errno on EOF:
>>>
>>>   If no characters were read, and the end-of-file indicator for
>>>   the stream is set, or if the stream is at end-of-file, the
>>>   end-of-file indicator for the stream shall be set and the
>>>   function shall return −1. If an error occurs, the error
>>>   indicator for the stream shall be set, and the function shall
>>>   return −1 and set errno to indicate the error.
>>
>> [snip]
>>
>>> I don't think that it matters in practice, but the "most" correct
>>> way to handle this would be to check if feof(3) is true to check
>>> for the non-errno case.
>>
>> Only if errors at EOF are guaranteed to be impossible.  Imagine
>> getdelim being able to read to the end and then failing to get memory
>> for the final NUL.  Other scenarios may be possible.
> 
> Good point. Instead of feof(3), checking ferror(3) should handle
> that properly. It's guaranteed to be set by getdelim for any
> error.

Only if we have a POSIXly correct implementation of getdelim(3). On
Linux its manpage doesn't mention the error indicator, but says that
the function started out as a GNU extension before becoming
standardized, so I'm not sure we can depend on that everywhere.

But we probably want to check for other errors.  They look unlikely
enough that we may get away with something like this:

-   if (errno == ENOMEM)
-   die("Out of memory, getdelim failed");
+   if (errno || ferror(fp))
+   die_errno(_("getdelim failed"));

NB: The other errors are EINVAL (input pointers are NULL or the
stream is invalid) and EOVERFLOW (read more than fits into ssize_t)
according to POSIX and the Linux manpage.

Update: Just noticed that on the BSDs getdelim(3) doesn't set errno
to ENOMEM on allocation failure, but does set the error indicator.
That might be an oversight on their part, but that means we
certainly *need* to check ferror().  And an unchanged errno can
mean ENOMEM there.  Ugh..

> An edge case is if the error indicator was already set before
> calling getdelim() and the errno was already set to ENOMEM. This
> could be fixed by checking ferror() before calling getdelim, but
> I'm not sure if that's necessary:

Treating an error as end-of-file is not a good idea.  An invalid
stream should not be passed to strbuf_getwholeline() in the first
place.  We could call die() or BUG(), but I think we may leave
that check to getdelim(3), unless we learn about an implementation
that is unprepared to reject streams with the error indicator set.

René


Re: [PATCH] strbuf: clear errno before calling getdelim(3)

2017-08-12 Thread René Scharfe
Am 12.08.2017 um 13:57 schrieb René Scharfe:
> Update: Just noticed that on the BSDs getdelim(3) doesn't set errno
> to ENOMEM on allocation failure, but does set the error indicator.
> That might be an oversight on their part, but that means we
> certainly *need* to check ferror().  And an unchanged errno can
> mean ENOMEM there.  Ugh..

I take that back.  The memory allocation function called by getdelim
will of course set errno on failure.  I got fooled by the manpages,
which don't mention ENOMEM, e.g.: https://man.openbsd.org/getdelim.

René


Re: [PATCH v4 4/4] add: modify already added files when --chmod is given

2017-08-12 Thread Thomas Gummerer
On 08/07, René Scharfe wrote:
> Am 14.09.2016 um 23:07 schrieb Thomas Gummerer:
> > When the chmod option was added to git add, it was hooked up to the diff
> > machinery, meaning that it only works when the version in the index
> > differs from the version on disk.
> > 
> > As the option was supposed to mirror the chmod option in update-index,
> > which always changes the mode in the index, regardless of the status of
> > the file, make sure the option behaves the same way in git add.
> > 
> > Signed-off-by: Thomas Gummerer 
> 
> Sorry for replying almost a year late, hopefully you're still interested.

Thanks for still replying :)

> > ---
> >   builtin/add.c  | 47 ---
> >   builtin/checkout.c |  2 +-
> >   builtin/commit.c   |  2 +-
> >   cache.h| 10 +-
> >   read-cache.c   | 14 ++
> >   t/t3700-add.sh | 50 ++
> >   6 files changed, 91 insertions(+), 34 deletions(-)
> > 
> > diff --git a/builtin/add.c b/builtin/add.c
> > index b1dddb4..595a0b2 100644
> > --- a/builtin/add.c
> > +++ b/builtin/add.c
> > @@ -26,10 +26,25 @@ static int patch_interactive, add_interactive, 
> > edit_interactive;
> >   static int take_worktree_changes;
> >   
> >   struct update_callback_data {
> > -   int flags, force_mode;
> > +   int flags;
> > int add_errors;
> >   };
> >   
> > +static void chmod_pathspec(struct pathspec *pathspec, int force_mode)
> 
> "int force_mode" looks like a binary (or perhaps ternary) flag, but
> actually it is a character and can only have the values '-' or '+'.
> In builtin/update-index.c it's called "char flip" and we probably should
> define it like this here as well.
> 
> > +{
> > +   int i;
> > +   
> > +   for (i = 0; i < active_nr; i++) {
> > +   struct cache_entry *ce = active_cache[i];
> > +
> > +   if (pathspec && !ce_path_match(ce, pathspec, NULL))
> > +   continue;
> > +
> > +   if (chmod_cache_entry(ce, force_mode) < 0)
> > +   fprintf(stderr, "cannot chmod '%s'", ce->name);
> 
> This error message is missing a newline.  In builtin/update-index.c we
> also show the attempted change (-x or +x); perhaps we want to do that
> here as well.

Thanks for catching this, both this and the above are worth changing
imo.  I see Ramsay already provided a patch for this in
https://public-inbox.org/git/aa004526-3e0d-66d4-287f-30abd2975...@ramsayjones.plus.com/.
Thanks Ramsay!

> Currently chmod_cache_entry() can only fail if ce is not a regular
> file or it's other parameter is neither '-' nor '+'.  We rule out the
> latter already in the argument parsing code.  The former can happen if
> we add a symlink, either explicitly or because it's in a directory
> we're specified.
> 
> I wonder if we even need to report anything, or under which conditions.
> If you have a file named dir/file and a symlink named dir/symlink then
> the interesting cases are:
> 
>   git add --chmod=.. dir/symlink
>   git add --chmod=.. dir/file dir/symlink
>   git add --chmod=.. dir
> 
> Warning about each case may be the most cautious thing to do, but
> documenting that --chmod has no effect on symlinks and keeping silent
> might be less annoying, especially in the last case.  What do you
> think?

I'm not sure about this.  While I do agree that it could be quite
annoying in the last case, it could potentially be a bit confusing to
not get any warning in the first case.  I don't have a strong opinion
either way.

> > @@ -342,13 +354,8 @@ int cmd_add(int argc, const char **argv, const char 
> > *prefix)
> > if (!show_only && ignore_missing)
> > die(_("Option --ignore-missing can only be used together with 
> > --dry-run"));
> >   
> > -   if (!chmod_arg)
> > -   force_mode = 0;
> > -   else if (!strcmp(chmod_arg, "-x"))
> > -   force_mode = 0666;
> > -   else if (!strcmp(chmod_arg, "+x"))
> > -   force_mode = 0777;
> > -   else
> > +   if (chmod_arg && ((chmod_arg[0] != '-' && chmod_arg[0] != '+') ||
> > + chmod_arg[1] != 'x' || chmod_arg[2]))
> > die(_("--chmod param '%s' must be either -x or +x"), chmod_arg);
> 
> That's the argument parsing code mentioned above.  The strcmp-based
> checks look nicer to me btw.  How about this?
> 
>   if (chmod_arg && strcmp(chmod_arg, "-x") && strcmp(chmod_arg, "+x"))
> 
> But that's just nitpicking.

I think this looks nicer indeed, thanks!  But it's probably not worth
a patch for just this unless we decide to change to not warn as you
mentioned above, and can fix this at the same time?

> René


Re: [PATCH 5/9] Convert various things to size_t

2017-08-12 Thread Martin Ågren
On 12 August 2017 at 10:47, Martin Koegler  wrote:
> From: Martin Koegler 
>
> ---
>  bisect.c| 2 +-
>  blame.c | 2 +-
>  builtin/fmt-merge-msg.c | 2 +-
>  builtin/mktag.c | 2 +-
>  dir.c   | 4 ++--
>  dir.h   | 2 +-
>  6 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/bisect.c b/bisect.c
> index 2549eaf..0580c82 100644
> --- a/bisect.c
> +++ b/bisect.c
> @@ -131,7 +131,7 @@ static void show_list(const char *debug, int counted, int 
> nr,
> struct commit *commit = p->item;
> unsigned flags = commit->object.flags;
> enum object_type type;
> -   unsigned long size;
> +   size_t size;
> char *buf = read_sha1_file(commit->object.sha1, &type, &size);
> const char *subject_start;
> int subject_len;

Would this need to be done in a patch where read_sha1_file is converted?


Error: Permition denied. git should not try to access root account if I work under common user

2017-08-12 Thread KES
Hi. 

When I use `git pull -v --rebase` command under user I got this error:

POST git-upload-pack (947 bytes)
POST git-upload-pack (452 bytes)
remote: warning: unable to access '/root/.config/git/attributes': Permission 
denied
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 3), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
>From https:///gitdev/main
   b446c31..f275d62  master -> origin/master
 = [up to date]  buy_dev-> origin/buy_dev
Created autostash: 48d1246
HEAD is now at 3ecd306 Do not guard by default
Changes from b446c313d9a9caccfeb34ef2c521c4ac03c24c6e to 
f275d62585211806e8e0b2350bbf4f0f3025da79:
 conf/app.staging.conf | 1 +
 1 file changed, 1 insertion(+)
First, rewinding head to replay your work on top of it...
Applying: BUGFIX: Do not fall if we are creating new database
Applying: Do not pull data from server. Do not count all rows
Applying: Do not guard by default
Applied autostash.


git should not try to access root account if I work under common user


Re: [PATCH 1/9] Convert pack-objects to size_t

2017-08-12 Thread Ramsay Jones


On 12/08/17 09:47, Martin Koegler wrote:
> From: Martin Koegler 
> 
> Signed-off-by: Martin Koegler 
> ---
>  builtin/pack-objects.c | 48 
>  1 file changed, 24 insertions(+), 24 deletions(-)
> 
> diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
> index aa70f80..f8db283 100644
> --- a/builtin/pack-objects.c
> +++ b/builtin/pack-objects.c
> @@ -56,7 +56,7 @@ static struct pack_idx_option pack_idx_opts;
>  static const char *base_name;
>  static int progress = 1;
>  static int window = 10;
> -static unsigned long pack_size_limit;
> +static size_t pack_size_limit;
>  static int depth = 50;
>  static int delta_search_threads;
>  static int pack_to_stdout;
> @@ -72,11 +72,11 @@ static int use_bitmap_index = -1;
>  static int write_bitmap_index;
>  static uint16_t write_bitmap_options;
>  
> -static unsigned long delta_cache_size = 0;
> -static unsigned long max_delta_cache_size = 256 * 1024 * 1024;
> -static unsigned long cache_max_small_delta_size = 1000;
> +static size_t delta_cache_size = 0;
> +static size_t max_delta_cache_size = 256 * 1024 * 1024;
> +static size_t cache_max_small_delta_size = 1000;
>  
> -static unsigned long window_memory_limit = 0;
> +static size_t window_memory_limit = 0;
>  
>  /*
>   * stats
> @@ -124,11 +124,11 @@ static void *get_delta(struct object_entry *entry)
>   return delta_buf;
>  }
>  
> -static unsigned long do_compress(void **pptr, unsigned long size)
> +static size_t do_compress(void **pptr, size_t size)
>  {
>   git_zstream stream;
>   void *in, *out;
> - unsigned long maxsize;
> + size_t maxsize;
>  
>   git_deflate_init(&stream, pack_compression_level);
>   maxsize = git_deflate_bound(&stream, size);
> @@ -149,13 +149,13 @@ static unsigned long do_compress(void **pptr, unsigned 
> long size)
>   return stream.total_out;
>  }
>  
> -static unsigned long write_large_blob_data(struct git_istream *st, struct 
> sha1file *f,
> +static size_t write_large_blob_data(struct git_istream *st, struct sha1file 
> *f,
>  const unsigned char *sha1)
>  {
>   git_zstream stream;
>   unsigned char ibuf[1024 * 16];
>   unsigned char obuf[1024 * 16];
> - unsigned long olen = 0;
> + size_t olen = 0;
>  
>   git_deflate_init(&stream, pack_compression_level);
>  
> @@ -196,7 +196,7 @@ static int check_pack_inflate(struct packed_git *p,
>   struct pack_window **w_curs,
>   off_t offset,
>   off_t len,
> - unsigned long expect)
> + size_t expect)
>  {
>   git_zstream stream;
>   unsigned char fakebuf[4096], *in;
> @@ -238,13 +238,13 @@ static void copy_pack_data(struct sha1file *f,
>  }
>  
>  /* Return 0 if we will bust the pack-size limit */
> -static unsigned long write_no_reuse_object(struct sha1file *f, struct 
> object_entry *entry,
> -unsigned long limit, int 
> usable_delta)
> +static size_t write_no_reuse_object(struct sha1file *f, struct object_entry 
> *entry,
> + size_t limit, int usable_delta)
>  {
>   size_t size, datalen;
>   unsigned char header[MAX_PACK_OBJECT_HEADER],
> dheader[MAX_PACK_OBJECT_HEADER];
> - unsigned hdrlen;
> + size_t hdrlen;
>   enum object_type type;
>   void *buf;
>   struct git_istream *st = NULL;
> @@ -350,17 +350,17 @@ static unsigned long write_no_reuse_object(struct 
> sha1file *f, struct object_ent
>  
>  /* Return 0 if we will bust the pack-size limit */
>  static off_t write_reuse_object(struct sha1file *f, struct object_entry 
> *entry,
> - unsigned long limit, int usable_delta)
> + size_t limit, int usable_delta)
>  {
>   struct packed_git *p = entry->in_pack;
>   struct pack_window *w_curs = NULL;
>   struct revindex_entry *revidx;
>   off_t offset;
>   enum object_type type = entry->type;
> - off_t datalen;
> + size_t datalen;

On 32-bit Linux, off_t is 64-bit and size_t is 32-bit.

Later in this function, datalen is set the the difference of
two (revidx) off_t offsets. I haven't applied and tried this
on my 32-bit Linux install yet (that installation only gets
booted about once a week), but I suspect a 'possible data-loss'
warning.

For other reasons, I don't think it is not possible for
a 32-bit system to create a packfile with an individual object
of size > 4GB anyway, so this may not be a problem in practice.
(a 32-bit system should be able to read such a packfile, presumably
created on a 64-bit system, and refuse to load such an object, of
course).

ATB,
Ramsay Jones


NO_MSGFMT

2017-08-12 Thread Dominik Mahrer (Teddy)

Hi all

I'm compiling git from source code on a mashine without msgfmt. This 
leads to compile errors. To be able to compile git I created a patch 
that at least works for me:


diff -Naur ../git-2.14.1.orig/Makefile ./Makefile
--- ../git-2.14.1.orig/Makefile 2017-08-09 21:54:31.0 +0200
+++ ./Makefile  2017-08-12 15:22:06.0 +0200
@@ -2261,7 +2261,11 @@
 endif

 po/build/locale/%/LC_MESSAGES/git.mo: po/%.po
+ifndef NO_MSGFMT
$(QUIET_MSGFMT)mkdir -p $(dir $@) && $(MSGFMT) -o $@ $<
+else
+   @echo Skipping file $@
+endif

 FIND_SOURCE_FILES = ( \
git ls-files \
@@ -2523,7 +2527,9 @@
 endif
 ifndef NO_TCLTK
$(MAKE) -C gitk-git install
-   $(MAKE) -C git-gui gitexecdir='$(gitexec_instdir_SQ)' install
+   ifndef NO_MSGFMT
+   $(MAKE) -C git-gui gitexecdir='$(gitexec_instdir_SQ)' install
+   endif
 endif
 ifneq (,$X)
 	$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) 
$(BUILT_INS) git$X)), test '$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p' -ef 
'$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p$X' || $(RM) 
'$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p';)




It would be great if it (or something similar) could be included in git.

Regards
Teddy


Re: [PATCH 2/9] Convert index-pack to size_t

2017-08-12 Thread Ramsay Jones


On 12/08/17 09:47, Martin Koegler wrote:
> From: Martin Koegler 
> 
> Signed-off-by: Martin Koegler 
> ---
>  builtin/index-pack.c | 26 +-
>  1 file changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/builtin/index-pack.c b/builtin/index-pack.c
> index 7f3ccd0..bf2d728 100644
> --- a/builtin/index-pack.c
> +++ b/builtin/index-pack.c
> @@ -435,7 +435,7 @@ static int is_delta_type(enum object_type type)
>   return (type == OBJ_REF_DELTA || type == OBJ_OFS_DELTA);
>  }
>  
> -static void *unpack_entry_data(off_t offset, unsigned long size,
> +static void *unpack_entry_data(off_t offset, size_t size,
>  enum object_type type, unsigned char *sha1)
>  {
>   static char fixed_buf[8192];
> @@ -444,10 +444,10 @@ static void *unpack_entry_data(off_t offset, unsigned 
> long size,
>   void *buf;
>   git_SHA_CTX c;
>   char hdr[32];
> - int hdrlen;
> + size_t hdrlen;
>  
>   if (!is_delta_type(type)) {
> - hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", typename(type), 
> size) + 1;
> + hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %" PRIuMAX, 
> typename(type), (uintmax_t)size) + 1;
>   git_SHA1_Init(&c);
>   git_SHA1_Update(&c, hdr, hdrlen);
>   } else
> @@ -489,7 +489,7 @@ static void *unpack_raw_entry(struct object_entry *obj,
> unsigned char *sha1)
>  {
>   unsigned char *p;
> - unsigned long size, c;
> + size_t size, c;
>   off_t base_offset;
>   unsigned shift;
>   void *data;
> @@ -551,11 +551,11 @@ static void *unpack_raw_entry(struct object_entry *obj,
>  }
>  
>  static void *unpack_data(struct object_entry *obj,
> -  int (*consume)(const unsigned char *, unsigned long, 
> void *),
> +  int (*consume)(const unsigned char *, size_t, void *),
>void *cb_data)
>  {
>   off_t from = obj[0].idx.offset + obj[0].hdr_size;
> - off_t len = obj[1].idx.offset - from;
> + size_t len = obj[1].idx.offset - from;

Similar comment to previous patch.

ATB,
Ramsay Jones



Re: [PATCH 3/9] Convert unpack-objects to size_t

2017-08-12 Thread Martin Ågren
On 12 August 2017 at 10:47, Martin Koegler  wrote:
> From: Martin Koegler 
>
> Signed-off-by: Martin Koegler 
> ---
>  builtin/unpack-objects.c | 20 ++--
>  1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
> index 001dd4b..0d8b6b3 100644
> --- a/builtin/unpack-objects.c
> +++ b/builtin/unpack-objects.c
> @@ -31,7 +31,7 @@ static struct fsck_options fsck_options = 
> FSCK_OPTIONS_STRICT;
>   */
>  struct obj_buffer {
> char *buffer;
> -   unsigned long size;
> +   size_t size;
>  };
>
>  static struct decoration obj_decorate;
> @@ -41,7 +41,7 @@ static struct obj_buffer *lookup_object_buffer(struct 
> object *base)
> return lookup_decoration(&obj_decorate, base);
>  }
>
> -static void add_object_buffer(struct object *object, char *buffer, unsigned 
> long size)
> +static void add_object_buffer(struct object *object, char *buffer, size_t 
> size)
>  {
> struct obj_buffer *obj;
> obj = xcalloc(1, sizeof(struct obj_buffer));
> @@ -93,7 +93,7 @@ static void use(int bytes)
> die(_("pack exceeds maximum allowed size"));
>  }
>
> -static void *get_data(unsigned long size)
> +static void *get_data(size_t size)
>  {
> git_zstream stream;
> void *buf = xmallocz(size);

"size" is handed over to a "git_zstream" and goes through zlib.c,
eventually ending up in zlib, which is outside Git's control, and which
seems to work with "uLong"s. How do these kind of changes interact with
zlib? For example, I wonder about this line further down in get_data:

if (stream.total_out == size && ret == Z_STREAM_END)

If total_out isn't converted, I guess this would never hit if "size" is
too large. And if total_out /is/ converted, I guess we'd risk truncation
in zlib_pre_call in zlib.c. Maybe that might cause Git and zlib to have
different ideas about how much data is available and/or should be
processed. Maybe we could then hit things like this in git.c:

if (s->z.total_out != s->total_out + bytes_produced)
die("BUG: total_out mismatch");

I am not very familiar with zlib, so apologies if this is just noise...

Martin


[PATCH/RFC] File commited with CRLF should roundtrip diff and apply

2017-08-12 Thread tboegi
From: Torsten Bögershausen 

When a file had been commited with CRLF and core.autocrlf is true,
the following does not roundtrip, `git apply` fails:

printf "Added line\r\n" >>file &&
git diff >patch &&
git checkout -- . &&
git apply patch

Before applying the patch, the file from working tree is converted into the
index format (clean filter, CRLF conversion, ...)
Here, when commited with CRLF, the line endings should not be converted.

Analyze the patch if there is any context line with CRLF,
or if any line with CRLF is to be removed.

If yes, the new flag has_crlf is set in "struct patch", and two things
will happen:
- read_old_data() will not convert CRLF into LF by calling
  convert_to_git(..., SAFE_CRLF_KEEP_CRLF);
- The WS_CR_AT_EOL bit is set in the "white space rule",
  CRLF are no longer treated as white space.

Thanks to Junio C Hamano, his input became the base for t4140.

Reported-by: Anthony Sottile 
Signed-off-by: Torsten Bögershausen 
---
 apply.c   | 37 -
 apply.h   |  4 
 t/t4140-apply-CRLF.sh | 46 ++
 3 files changed, 78 insertions(+), 9 deletions(-)
 create mode 100755 t/t4140-apply-CRLF.sh

diff --git a/apply.c b/apply.c
index f2d599141d..63455cd65f 100644
--- a/apply.c
+++ b/apply.c
@@ -220,6 +220,7 @@ struct patch {
unsigned int recount:1;
unsigned int conflicted_threeway:1;
unsigned int direct_to_threeway:1;
+   unsigned int has_crlf:1;
struct fragment *fragments;
char *result;
size_t resultsize;
@@ -1662,6 +1663,17 @@ static void check_whitespace(struct apply_state *state,
record_ws_error(state, result, line + 1, len - 2, state->linenr);
 }
 
+/* Check if the patch has context lines with CRLF or
+   the patch wants to remove lines with CRLF */
+static void check_old_for_crlf(struct patch *patch, const char *line, int len)
+{
+   if (len >= 2 && line[len-1] == '\n' && line[len-2] == '\r') {
+   patch->ws_rule |= WS_CR_AT_EOL;
+   patch->has_crlf = 1;
+   }
+}
+
+
 /*
  * Parse a unified diff. Note that this really needs to parse each
  * fragment separately, since the only way to know the difference
@@ -1712,11 +1724,13 @@ static int parse_fragment(struct apply_state *state,
if (!deleted && !added)
leading++;
trailing++;
+   check_old_for_crlf(patch, line, len);
if (!state->apply_in_reverse &&
state->ws_error_action == correct_ws_error)
check_whitespace(state, line, len, 
patch->ws_rule);
break;
case '-':
+   check_old_for_crlf(patch, line, len);
if (state->apply_in_reverse &&
state->ws_error_action != nowarn_ws_error)
check_whitespace(state, line, len, 
patch->ws_rule);
@@ -2268,8 +2282,10 @@ static void show_stats(struct apply_state *state, struct 
patch *patch)
add, pluses, del, minuses);
 }
 
-static int read_old_data(struct stat *st, const char *path, struct strbuf *buf)
+static int read_old_data(struct stat *st, const char *path, struct strbuf 
*buf, int flags)
 {
+   enum safe_crlf safe_crlf = flags & APPLY_FLAGS_CR_AT_EOL ?
+   SAFE_CRLF_KEEP_CRLF : SAFE_CRLF_FALSE;
switch (st->st_mode & S_IFMT) {
case S_IFLNK:
if (strbuf_readlink(buf, path, st->st_size) < 0)
@@ -2278,7 +2294,7 @@ static int read_old_data(struct stat *st, const char 
*path, struct strbuf *buf)
case S_IFREG:
if (strbuf_read_file(buf, path, st->st_size) != st->st_size)
return error(_("unable to open or read %s"), path);
-   convert_to_git(&the_index, path, buf->buf, buf->len, buf, 0);
+   convert_to_git(&the_index, path, buf->buf, buf->len, buf, 
safe_crlf);
return 0;
default:
return -1;
@@ -3385,7 +3401,8 @@ static int load_patch_target(struct apply_state *state,
 const struct cache_entry *ce,
 struct stat *st,
 const char *name,
-unsigned expected_mode)
+unsigned expected_mode,
+int flags)
 {
if (state->cached || state->check_index) {
if (read_file_or_gitlink(ce, buf))
@@ -3399,7 +3416,7 @@ static int load_patch_target(struct apply_state *state,
} else if (has_symlink_leading_path(name, strlen(name))) {
return error(_("reading from '%s' beyond a symbolic 
link"), name);
} else {
-   if (read_old_data(st, name, buf))
+   if (read_old_dat

[PATCH/RFC] convert: Add SAFE_CRLF_KEEP_CRLF

2017-08-12 Thread tboegi
From: Torsten Bögershausen 

When convert_to_git() is called, the caller may want to keep CRLF
to be kept as CRLF (and not converted into LF).

This will be used in the next commit, when apply works with files that have
CRLF and patches are applied onto these files.

Add the new value "SAFE_CRLF_KEEP_CRLF" to safe_crlf.

Prepare convert_to_git() to be able to run the clean filter,
skip the CRLF conversion and run the ident filter.

Signed-off-by: Torsten Bögershausen 
---
 convert.c | 10 ++
 convert.h |  3 ++-
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/convert.c b/convert.c
index deaf0ba7b3..040123b4fe 100644
--- a/convert.c
+++ b/convert.c
@@ -1104,10 +1104,12 @@ int convert_to_git(const struct index_state *istate,
src = dst->buf;
len = dst->len;
}
-   ret |= crlf_to_git(istate, path, src, len, dst, ca.crlf_action, 
checksafe);
-   if (ret && dst) {
-   src = dst->buf;
-   len = dst->len;
+   if (checksafe != SAFE_CRLF_KEEP_CRLF) {
+   ret |= crlf_to_git(istate, path, src, len, dst, ca.crlf_action, 
checksafe);
+   if (ret && dst) {
+   src = dst->buf;
+   len = dst->len;
+   }
}
return ret | ident_to_git(path, src, len, dst, ca.ident);
 }
diff --git a/convert.h b/convert.h
index cecf59d1aa..cabd5ed6dd 100644
--- a/convert.h
+++ b/convert.h
@@ -10,7 +10,8 @@ enum safe_crlf {
SAFE_CRLF_FALSE = 0,
SAFE_CRLF_FAIL = 1,
SAFE_CRLF_WARN = 2,
-   SAFE_CRLF_RENORMALIZE = 3
+   SAFE_CRLF_RENORMALIZE = 3,
+   SAFE_CRLF_KEEP_CRLF = 4
 };
 
 extern enum safe_crlf safe_crlf;
-- 
2.14.1.145.gb3622a4ee9



Re: [PATCH v2] tree-walk: convert fill_tree_descriptor() to object_id

2017-08-12 Thread brian m. carlson
On Sat, Aug 12, 2017 at 10:32:59AM +0200, René Scharfe wrote:
> All callers of fill_tree_descriptor() have been converted to object_id
> already, so convert that function as well.  As a nice side-effect we get
> rid of NULL checks in tree-diff.c, as fill_tree_descriptor() already
> does them for us.
> 
> Helped-by: Johannes Sixt 
> Signed-off-by: Rene Scharfe 

This looks good to me.  I had written a very similar patch for a later
series, and they're pretty much identical.
-- 
brian m. carlson / brian with sandals: Houston, Texas, US
https://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: https://keybase.io/bk2204


signature.asc
Description: PGP signature


IMMEDIATE REPLY NEEDED.

2017-08-12 Thread Alaine Kamba
Dear,

My name is Mr Alaine Kamba, I am the Bill and Exchange (assistant)
Manager of Bank of Africa Ouagadougou, Burkina Faso. In my department
I discovered an abandoned sum of eighteen million three hundred
thousand United State of American dollars (18.3MILLION USA DOLLARS)
in an account that belongs to one of our foreign customer who died in
airline that crashed on 4th October 2001.

Since I got information about his death I have been expecting his next
of kin to come over and claim his money because we can not release it
unless somebody applies for it as the next of kin or relation to the
deceased as indicated in our banking guidelines, but unfortunately we
learnt that all his supposed next of kin or relation died alongside
with him in the plane crash leaving nobody behind for the claim. It is
therefore upon this discovery that I decided to make this business
proposal to you and release the money to you as next of kin or
relation to the deceased for safety and subsequent disbursement since
nobody is coming for it and I don't want the money to go into the bank
treasury as unclaimed bill.

You will be entitled with 40% of the total sum while 60% will be for
me after which I will visit your Country to invest my own share when
the fund is successfully transferred into your account, Please I would
like you to keep this transaction confidential and as a top secret as
you may wish to know that I am a bank official.

Yours sincerely,
Mr Alaine Kamba.


[PATCH v3] am: fix signoff when other trailers are present

2017-08-12 Thread Phillip Wood
From: Phillip Wood 

If there was no 'Signed-off-by:' trailer but another trailer such as
'Reported-by:' then 'git am --signoff' would add a blank line between
the existing trailers and the added 'Signed-off-by:' line. e.g.

Rebase accepts '--rerere-autoupdate' as an option but only honors
it if '-m' is also given. Fix it for a non-interactive rebase by
passing on the option to 'git am' and 'git cherry-pick'.

Reported-by: Junio C Hamano 

Signed-off-by: Phillip Wood 

Fix by using the code provided for this purpose in sequencer.c.
Change the tests so that they check the formatting of the
'Signed-off-by:' lines rather than just grepping for them.

Signed-off-by: Phillip Wood 
---
I've changed the test names and cleaned up the printf in the tests as
Junio suggested. Otherwise this is unchanged from the previous version.

 builtin/am.c  | 26 +
 t/t4150-am.sh | 89 +--
 2 files changed, 69 insertions(+), 46 deletions(-)

diff --git a/builtin/am.c b/builtin/am.c
index 
c973bd96dcb5d630d56e935733bfa4530ccd2872..3aaef59676452fd2e7c6d4a375dc7c95558744c6
 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -1181,34 +1181,10 @@ static void NORETURN die_user_resolve(const struct 
am_state *state)
  */
 static void am_append_signoff(struct am_state *state)
 {
-   char *cp;
-   struct strbuf mine = STRBUF_INIT;
struct strbuf sb = STRBUF_INIT;
 
strbuf_attach(&sb, state->msg, state->msg_len, state->msg_len);
-
-   /* our sign-off */
-   strbuf_addf(&mine, "\n%s%s\n",
-   sign_off_header,
-   fmt_name(getenv("GIT_COMMITTER_NAME"),
-getenv("GIT_COMMITTER_EMAIL")));
-
-   /* Does sb end with it already? */
-   if (mine.len < sb.len &&
-   !strcmp(mine.buf, sb.buf + sb.len - mine.len))
-   goto exit; /* no need to duplicate */
-
-   /* Does it have any Signed-off-by: in the text */
-   for (cp = sb.buf;
-cp && *cp && (cp = strstr(cp, sign_off_header)) != NULL;
-cp = strchr(cp, '\n')) {
-   if (sb.buf == cp || cp[-1] == '\n')
-   break;
-   }
-
-   strbuf_addstr(&sb, mine.buf + !!cp);
-exit:
-   strbuf_release(&mine);
+   append_signoff(&sb, 0, 0);
state->msg = strbuf_detach(&sb, &state->msg_len);
 }
 
diff --git a/t/t4150-am.sh b/t/t4150-am.sh
index 
44807e218d7016f58bd41b89af71104a37f31a8b..ae23adfb7548a4a28aaa52e689094f727f0f4cf2
 100755
--- a/t/t4150-am.sh
+++ b/t/t4150-am.sh
@@ -40,6 +40,8 @@ test_expect_success 'setup: messages' '
dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio
dignissim qui blandit praesent luptatum zzril delenit augue duis dolore 
te
feugait nulla facilisi.
+
+   Reported-by: A N Other 
EOF
 
cat >failmail <<-\EOF &&
@@ -93,7 +95,7 @@ test_expect_success setup '
echo world >>file &&
git add file &&
test_tick &&
-   git commit -s -F msg &&
+   git commit -F msg &&
git tag second &&
 
git format-patch --stdout first >patch1 &&
@@ -124,8 +126,6 @@ test_expect_success setup '
echo "Date: $GIT_AUTHOR_DATE" &&
echo &&
sed -e "1,2d" msg &&
-   echo &&
-   echo "Signed-off-by: $GIT_COMMITTER_NAME 
<$GIT_COMMITTER_EMAIL>" &&
echo "---" &&
git diff-tree --no-commit-id --stat -p second
} >patch1-stgit.eml &&
@@ -144,8 +144,6 @@ test_expect_success setup '
echo "# Parent  $_z40" &&
cat msg &&
echo &&
-   echo "Signed-off-by: $GIT_COMMITTER_NAME 
<$GIT_COMMITTER_EMAIL>" &&
-   echo &&
git diff-tree --no-commit-id -p second
} >patch1-hg.eml &&
 
@@ -470,13 +468,15 @@ test_expect_success 'am --signoff adds Signed-off-by: 
line' '
git reset --hard &&
git checkout -b master2 first &&
git am --signoff expected &&
-   echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" 
>>expected &&
-   git cat-file commit HEAD^ | grep "Signed-off-by:" >actual &&
-   test_cmp expected actual &&
-   echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" 
>expected &&
-   git cat-file commit HEAD | grep "Signed-off-by:" >actual &&
-   test_cmp expected actual
+   {
+   printf "third\n\nSigned-off-by: %s <%s>\n\n" \
+   "$GIT_COMMITTER_NAME" "$GIT_COMMITTER_EMAIL" &&
+   cat msg &&
+   printf "Signed-off-by: %s <%s>\n\n" \
+   "$GIT_COMMITTER_NAME" "$GIT_COMMITTER_EMAIL"
+   } >expected-log &&
+   git log --pretty=%B -2 HEAD >actual &&
+   test_cmp expected-log actual
 '
 
 test_expect_success 'am stays in branch' '
@@ -485,18 +485,65 @@ test_expect_success 'am stays i

Re: Error: Permition denied. git should not try to access root account if I work under common user

2017-08-12 Thread brian m. carlson
On Sat, Aug 12, 2017 at 04:22:08PM +0300, KES wrote:
> Hi.
> 
> When I use `git pull -v --rebase` command under user I got this error:
> 
> POST git-upload-pack (947 bytes)
> POST git-upload-pack (452 bytes)
> remote: warning: unable to access '/root/.config/git/attributes': Permission 
> denied
> remote: Counting objects: 4, done.
> remote: Compressing objects: 100% (4/4), done.
> remote: Total 4 (delta 3), reused 0 (delta 0)

These messages are from the remote side (the machine you're pulling
from).  Something there is telling git that /root is the proper home
directory, and it's trying to read that file.

You should find out whoever is running that remote server and tell them
that their server is misconfigured.
-- 
brian m. carlson / brian with sandals: Houston, Texas, US
https://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: https://keybase.io/bk2204


signature.asc
Description: PGP signature


[BUG] git am sometimes unable to apply git format-patch output file

2017-08-12 Thread Soul Trace

Hello.

Using git i have found that git am command may sometimes fail to apply 
patch file which was created by the git am command.



Steps to reproduce:

# 1. Clone test repository:

git clone https://github.com/S-trace/git_am_bug_test.git

# 2. Format patch file for last commit:

git format-patch HEAD~

# 3. Go to previous commit:

git checkout HEAD~

# 4. Apply back patch file created in step 2:

git am 0001-UPDATE-Update-ascend_MOGOLIA_ULG_normal.xml.patch

The git am command fails on my machine with the following error message:

Applying: Update ascend_MOGOLIA_ULG_normal.xml
.git/rebase-apply/patch:6522: trailing whitespace.

error: patch failed: ascend_MOGOLIA_ULG_normal.xml:1
error: ascend_MOGOLIA_ULG_normal.xml: patch does not apply
Patch failed at 0001 Update ascend_MOGOLIA_ULG_normal.xml
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".


But patch command can handle this patch file:

patch -p1 -i 0001-UPDATE-Update-ascend_MOGOLIA_ULG_normal.xml.patch


Versions information:

git --version
git version 2.11.0

patch --version
GNU patch 2.7.5
Copyright (C) 2003, 2009-2012 Free Software Foundation, Inc.
Copyright (C) 1988 Larry Wall

License GPLv3+: GNU GPL version 3 or later 
.

This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Larry Wall and Paul Eggert

uname -a
Linux omen 4.10.0-26-generic #30-Ubuntu SMP Tue Jun 27 09:30:12 UTC 2017 
x86_64 x86_64 x86_64 GNU/Linux


lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:Ubuntu 17.04
Release:17.04
Codename:   zesty


Thank you.



Re: [BUG] git am sometimes unable to apply git format-patch output file

2017-08-12 Thread Torsten Bögershausen
On Sat, Aug 12, 2017 at 07:02:59PM +0300, Soul Trace wrote:
> Hello.
> 
> Using git i have found that git am command may sometimes fail to apply patch
> file which was created by the git am command.
> 
> 
> Steps to reproduce:

Excellent, thanks so much for the detailed bug report.
This kind of information is really appreciated.

Why did I say excellent ?
Because I am working on a patch, which -should- fix exactly this kind of issues.
I send out a patch earlier this day, but it doesn't fix your issue, even if it 
should.
I hope to have a fix soonish.


Re: [BUG] git am sometimes unable to apply git format-patch output file

2017-08-12 Thread Torsten Bögershausen
On Sat, Aug 12, 2017 at 06:20:23PM +0200, Torsten Bögershausen wrote:
> On Sat, Aug 12, 2017 at 07:02:59PM +0300, Soul Trace wrote:
> > Hello.
> > 
> > Using git i have found that git am command may sometimes fail to apply patch
> > file which was created by the git am command.
> > 
> > 
> > Steps to reproduce:
> 
> Excellent, thanks so much for the detailed bug report.
> This kind of information is really appreciated.
> 
> Why did I say excellent ?
> Because I am working on a patch, which -should- fix exactly this kind of 
> issues.
> I send out a patch earlier this day, but it doesn't fix your issue, even if 
> it should.
> I hope to have a fix soonish.

I need to correct mysef, a litte bit, this doesn't seem to be a bug, but a 
feature.
There are 2 things to be noticed:
- The xml file has been commited with CRLF
- git am strips the CR (because they -may- have been added by a mail program)

There are 2 different solutions:
a) Use git am --keep-cr
b) "Normalize" the xml file(s), and commit them to have LF in the repo,
they can still have CRLF in the work tree, if needed.
This is done by
echo "*.xml text" >>.gitattributes
touch *.xml
git add *.xml .gitattributes
git commit -m "Normalize xml files"


If you really need the xml files with CRLF, use this line instead:
echo "*.xml eol=CRLF" >>.gitattributes

HTH
/Torsten


[no subject]

2017-08-12 Thread Stephanie Gomes
How I work this?

Sent from my iPhone


Re: [PATCH] strbuf: clear errno before calling getdelim(3)

2017-08-12 Thread Jeff King
On Sat, Aug 12, 2017 at 01:57:06PM +0200, René Scharfe wrote:

> But we probably want to check for other errors.  They look unlikely
> enough that we may get away with something like this:
> 
>   -   if (errno == ENOMEM)
>   -   die("Out of memory, getdelim failed");
>   +   if (errno || ferror(fp))
>   +   die_errno(_("getdelim failed"));
> 
> NB: The other errors are EINVAL (input pointers are NULL or the
> stream is invalid) and EOVERFLOW (read more than fits into ssize_t)
> according to POSIX and the Linux manpage.

Can't we also get any of the errors that fgetc() would return. I.e., any
normal read errors? We should return EOF on those, not die (and the
caller can check ferror()).

-Peff


Re: [PATCH v2 1/2] format-patch: have progress option while generating patches

2017-08-12 Thread Jeff King
On Sat, Aug 12, 2017 at 09:06:18AM +0100, Philip Oakley wrote:

> > > > + progress = start_progress_delay(_("Generating patches"), total, 0, 1);
> > > 
> > > I don't really have an opinion on a 1 second delay versus 2. I thought
> > > we used 2 pretty consistently, though grepping around I do see a couple
> > > of 1's. It probably doesn't matter, but just a curiosity.
> > 
> > Yeah, I also thought 2-second was what we used by default.  Perhaps
> > we would want to bring others in line?
> 
>  Surely the choice should depend on the purpose of the delay. IIRC
> the 1 second between patches on the formal 'sent' time was simply to ensure
> the patches had the right sequence. Delays for warnings and progress have
> different purposes, so I think it's more about the purpose than
> standardising the time (along with expectations [least surprise] if other
> messages are displayed).

I think you're confusing two unrelated things. There's a 1-second fake
time-advance on patches, but that's done by send-email, not
format-patch.

Here we're just talking about calls to start_progress_delay(), and how
long it waits before deciding that the operation is slow enough to show
progress. Blame, rename detection, and checkout use 1 second. Prune,
prune-packed, and connectivity checks all use 2 seconds. I doubt it
matters all that much, but presumably the purpose in all is "how long
before a user starts to wonder if things are actually happening", which
is probably command-independent.

-Peff


Re: [RFC] clang-format: outline the git project's coding style

2017-08-12 Thread Jeff King
On Fri, Aug 11, 2017 at 09:39:11PM -0700, Junio C Hamano wrote:

> > Yeah, I just dug in the archive. The script I ran way back when was
> > actually clang-format-diff.
> 
> I am confident with the competence of people around here that we can
> come up with a reasonable checker for obvious style violations. In
> the worst case, we could customize and/or tweak checkpatch.pl and
> start from there.

I am confident we _can_, too. My question is whether we will. :)

> Assuming that we can have such a checker, I am more interested in
> the way how people envision such a checker fits in our workflow to
> help people.  Earlier Dscho floated an idea to integrate with the
> GitHub pull requests in a way similar to how Travis and SubmitGit
> are triggered, and I can sort of see how it may help, but I haven't
> seen ideas from others.

Yeah, I agree. I assume most people already run "make test" locally. I'd
be happy enough if we started with a "make style" that offers style
suggestions for you to accept. From there we can grow into
"automatically apply suggestions" and integrating with things like
submitGit.

-Peff


Re: NO_MSGFMT

2017-08-12 Thread Jeff King
On Sat, Aug 12, 2017 at 03:44:17PM +0200, Dominik Mahrer (Teddy) wrote:

> Hi all
> 
> I'm compiling git from source code on a mashine without msgfmt. This leads
> to compile errors. To be able to compile git I created a patch that at least
> works for me:

Try:

  make NO_MSGFMT=Nope NO_GETTEXT=Nope

This also works:

  make NO_GETTEXT=Nope NO_TCLTK=Nope

The flags to avoid gettext/msgfmt are sadly different between git itself
and git-gui/gitk, which we include as a subproject. It would be a useful
patch to harmonize though (probably by accepting both in all places for
compatibility).

-Peff


Bug?: git archive exclude pathspec and gitattributes export-ignore

2017-08-12 Thread David Adam
Hi all,

I think I have a bug in git (tested 2.11.0 on Debian 8, 2.14.1 on OS X and 
2.14.1.145.gb3622a4 on OS X).

Given a repository with an export-ignore directive for a subdirectory in 
.gitattributes, `git archive` with a pathspec that excludes a different 
subdirectory produces no output file and git exits with -1 as the return 
status.

As shown:

   > git init foo && cd foo
   Initialized empty Git repository in /Users/david/src/foo/.git/
   > mkdir a b
   > touch {a,b}/somefile
   > echo "/a export-ignore" >> .gitattributes
   > git add .
   > git commit -m "Initial commit"
   [master (root-commit) 53527a7] Initial commit
3 files changed, 1 insertion(+)
create mode 100644 .gitattributes
create mode 100644 a/somefile
create mode 100644 b/somefile
   > git archive --verbose master ':(top)' ':(exclude)b*'
   .gitattributes
   > echo $?
   255

If this is intended behaviour, is there any way of achieving the goal of 
excluding a subdirectory not listed as export-ignore? Using the exclude 
pathspec ":(exclude)b" produces an empty subdirectory b in the output, 
which I would like to avoid.

This is a reduced testcase; my goal is to end up with two archives, one 
containing directory b only, and one containing everything except for 
directory b - so I can't just add 'b export-ignore' to gitattributes.

Thanks

David Adam
zanc...@ucc.gu.uwa.edu.au


Re: [PATCH] strbuf: clear errno before calling getdelim(3)

2017-08-12 Thread René Scharfe
Am 13.08.2017 um 06:32 schrieb Jeff King:
> On Sat, Aug 12, 2017 at 01:57:06PM +0200, René Scharfe wrote:
> 
>> But we probably want to check for other errors.  They look unlikely
>> enough that we may get away with something like this:
>>
>>  -   if (errno == ENOMEM)
>>  -   die("Out of memory, getdelim failed");
>>  +   if (errno || ferror(fp))
>>  +   die_errno(_("getdelim failed"));
>>
>> NB: The other errors are EINVAL (input pointers are NULL or the
>> stream is invalid) and EOVERFLOW (read more than fits into ssize_t)
>> according to POSIX and the Linux manpage.
> 
> Can't we also get any of the errors that fgetc() would return. I.e., any
> normal read errors? We should return EOF on those, not die (and the
> caller can check ferror()).

Yes, we can get those as well, and leaving error checking to the caller
is a flexible way to handle them.  

Many of the existing callers don't seem to be bother, though.

René


Re: [PATCH] strbuf: clear errno before calling getdelim(3)

2017-08-12 Thread Jeff King
On Sun, Aug 13, 2017 at 07:51:34AM +0200, René Scharfe wrote:

> Am 13.08.2017 um 06:32 schrieb Jeff King:
> > On Sat, Aug 12, 2017 at 01:57:06PM +0200, René Scharfe wrote:
> > 
> >> But we probably want to check for other errors.  They look unlikely
> >> enough that we may get away with something like this:
> >>
> >>-   if (errno == ENOMEM)
> >>-   die("Out of memory, getdelim failed");
> >>+   if (errno || ferror(fp))
> >>+   die_errno(_("getdelim failed"));
> >>
> >> NB: The other errors are EINVAL (input pointers are NULL or the
> >> stream is invalid) and EOVERFLOW (read more than fits into ssize_t)
> >> according to POSIX and the Linux manpage.
> > 
> > Can't we also get any of the errors that fgetc() would return. I.e., any
> > normal read errors? We should return EOF on those, not die (and the
> > caller can check ferror()).
> 
> Yes, we can get those as well, and leaving error checking to the caller
> is a flexible way to handle them.  
> 
> Many of the existing callers don't seem to be bother, though.

Yes, but keep in mind that we need to match the non-getdelim()
implementation here (which itself tries to behave like more or less like
a dynamic fgets, including the eof/error handling). Because the callers
don't know which one they're getting.

-Peff


Re: git-describe --contains

2017-08-12 Thread Davide Cavallari
Thanks Andreas and Nicholas, I'll check it out.