Git development
 help / color / mirror / Atom feed
* [PATCH 2/5] fix "git add --ignore-errors" to ignore pathspec errors
From: Luke Dashjr @ 2009-08-13  3:20 UTC (permalink / raw)
  To: git; +Cc: Luke Dashjr
In-Reply-To: <1250133624-2272-1-git-send-email-luke-jr+git@utopios.org>

Unmatched files are errors, and should be ignored with the rest of them.

Signed-off-by: Luke Dashjr <luke-jr+git@utopios.org>
---
 builtin-add.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/builtin-add.c b/builtin-add.c
index 0597fb9..e3132c8 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -280,6 +280,8 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 		add_interactive = 1;
 	if (add_interactive)
 		exit(interactive_add(argc - 1, argv + 1, prefix));
+	if (ignore_add_errors)
+		ignore_unmatch = 1;
 
 	if (edit_interactive)
 		return(edit_patch(argc, argv, prefix));
-- 
1.6.3.3

^ permalink raw reply related

* [PATCH 4/5] implement error_errno and warning_errno
From: Luke Dashjr @ 2009-08-13  3:20 UTC (permalink / raw)
  To: git; +Cc: Luke Dashjr
In-Reply-To: <1250133624-2272-3-git-send-email-luke-jr+git@utopios.org>

This allows for easier conversion of code that currently does a (fatal)
die_errno to a safer error (which can be ignored), or perhaps even warning
status.

Signed-off-by: Luke Dashjr <luke-jr+git@utopios.org>
---
 git-compat-util.h |    2 +
 usage.c           |   66 ++++++++++++++++++++++++-----------------------------
 2 files changed, 32 insertions(+), 36 deletions(-)

diff --git a/git-compat-util.h b/git-compat-util.h
index 9f941e4..25d4c1e 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -181,7 +181,9 @@ extern void usage(const char *err) NORETURN;
 extern void die(const char *err, ...) NORETURN __attribute__((format (printf, 1, 2)));
 extern void die_errno(const char *err, ...) NORETURN __attribute__((format (printf, 1, 2)));
 extern int error(const char *err, ...) __attribute__((format (printf, 1, 2)));
+extern int error_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
 extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2)));
+extern void warning_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
 
 extern void set_die_routine(void (*routine)(const char *err, va_list params) NORETURN);
 
diff --git a/usage.c b/usage.c
index b6aea45..dce90dc 100644
--- a/usage.c
+++ b/usage.c
@@ -39,7 +39,7 @@ static void warn_builtin(const char *warn, va_list params)
 static void (*usage_routine)(const char *err) NORETURN = usage_builtin;
 static void (*die_routine)(const char *err, va_list params) NORETURN = die_builtin;
 static void (*error_routine)(const char *err, va_list params) = error_builtin;
-static void (*warn_routine)(const char *err, va_list params) = warn_builtin;
+static void (*warning_routine)(const char *err, va_list params) = warn_builtin;
 
 void set_die_routine(void (*routine)(const char *err, va_list params) NORETURN)
 {
@@ -51,19 +51,8 @@ void usage(const char *err)
 	usage_routine(err);
 }
 
-void die(const char *err, ...)
+static void _e_errno(const char *fmt, char *fmt_with_err, size_t sizeof_fmt_with_err)
 {
-	va_list params;
-
-	va_start(params, err);
-	die_routine(err, params);
-	va_end(params);
-}
-
-void die_errno(const char *fmt, ...)
-{
-	va_list params;
-	char fmt_with_err[1024];
 	char str_error[256], *err;
 	int i, j;
 
@@ -81,28 +70,33 @@ void die_errno(const char *fmt, ...)
 		}
 	}
 	str_error[j] = 0;
-	snprintf(fmt_with_err, sizeof(fmt_with_err), "%s: %s", fmt, str_error);
-
-	va_start(params, fmt);
-	die_routine(fmt_with_err, params);
-	va_end(params);
-}
-
-int error(const char *err, ...)
-{
-	va_list params;
-
-	va_start(params, err);
-	error_routine(err, params);
-	va_end(params);
-	return -1;
+	snprintf(fmt_with_err, sizeof_fmt_with_err, "%s: %s", fmt, str_error);
 }
 
-void warning(const char *warn, ...)
-{
-	va_list params;
-
-	va_start(params, warn);
-	warn_routine(warn, params);
-	va_end(params);
-}
+#define BUILD_E(RTYPE, NAME, CODE)  \
+RTYPE NAME(const char *err, ...)  \
+{  \
+	va_list params;  \
+  \
+	va_start(params, err);  \
+	NAME ## _routine(err, params);  \
+	va_end(params);  \
+	CODE  \
+}  \
+  \
+RTYPE NAME ## _errno(const char *fmt, ...)  \
+{  \
+	va_list params;  \
+	static char fmt_with_err[1024];  \
+  \
+	va_start(params, fmt);  \
+	_e_errno(fmt, fmt_with_err, sizeof(fmt_with_err));  \
+	NAME ## _routine(fmt_with_err, params);  \
+	va_end(params);  \
+	CODE  \
+}  \
+// END OF BUILD_E MACRO
+
+BUILD_E(void, die, )
+BUILD_E(int, error, return -1;)
+BUILD_E(void, warning, )
-- 
1.6.3.3

^ permalink raw reply related

* [PATCH 1/5] port --ignore-unmatch to "git add"
From: Luke Dashjr @ 2009-08-13  3:20 UTC (permalink / raw)
  To: git; +Cc: Luke Dashjr
In-Reply-To: <200908121726.52121.luke-jr@utopios.org>

"git rm" has a --ignore-unmatch option that is also applicable to "git add"
and may be useful for persons wanting to ignore unmatched arguments, but not
all errors.

Signed-off-by: Luke Dashjr <luke-jr+git@utopios.org>
---
 builtin-add.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/builtin-add.c b/builtin-add.c
index 581a2a1..0597fb9 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -19,6 +19,7 @@ static const char * const builtin_add_usage[] = {
 };
 static int patch_interactive, add_interactive, edit_interactive;
 static int take_worktree_changes;
+static int ignore_unmatch = 0;
 
 static void fill_pathspec_matches(const char **pathspec, char *seen, int specs)
 {
@@ -63,7 +64,7 @@ static void prune_directory(struct dir_struct *dir, const char **pathspec, int p
 	fill_pathspec_matches(pathspec, seen, specs);
 
 	for (i = 0; i < specs; i++) {
-		if (!seen[i] && pathspec[i][0] && !file_exists(pathspec[i]))
+		if (!seen[i] && pathspec[i][0] && !file_exists(pathspec[i]) && !ignore_unmatch)
 			die("pathspec '%s' did not match any files",
 					pathspec[i]);
 	}
@@ -108,7 +109,7 @@ static void refresh(int verbose, const char **pathspec)
 	refresh_index(&the_index, verbose ? REFRESH_SAY_CHANGED : REFRESH_QUIET,
 		      pathspec, seen);
 	for (i = 0; i < specs; i++) {
-		if (!seen[i])
+		if (!seen[i] && !ignore_unmatch)
 			die("pathspec '%s' did not match any files", pathspec[i]);
 	}
         free(seen);
@@ -226,6 +227,8 @@ static struct option builtin_add_options[] = {
 	OPT_BOOLEAN('A', "all", &addremove, "add all, noticing removal of tracked files"),
 	OPT_BOOLEAN( 0 , "refresh", &refresh_only, "don't add, only refresh the index"),
 	OPT_BOOLEAN( 0 , "ignore-errors", &ignore_add_errors, "just skip files which cannot be added because of errors"),
+	OPT_BOOLEAN( 0 , "ignore-unmatch", &ignore_unmatch,
+				"exit with a zero status even if nothing matched"),
 	OPT_END(),
 };
 
-- 
1.6.3.3

^ permalink raw reply related

* [PATCH 3/5] Document --ignore-unmatch in git-add.txt
From: Luke Dashjr @ 2009-08-13  3:20 UTC (permalink / raw)
  To: git; +Cc: Luke Dashjr
In-Reply-To: <1250133624-2272-2-git-send-email-luke-jr+git@utopios.org>

Signed-off-by: Luke Dashjr <luke-jr+git@utopios.org>
---
 Documentation/git-add.txt |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
index ab1943c..6b93b4e 100644
--- a/Documentation/git-add.txt
+++ b/Documentation/git-add.txt
@@ -10,7 +10,8 @@ SYNOPSIS
 [verse]
 'git add' [-n] [-v] [--force | -f] [--interactive | -i] [--patch | -p]
 	  [--edit | -e] [--all | [--update | -u]] [--intent-to-add | -N]
-	  [--refresh] [--ignore-errors] [--] <filepattern>...
+	  [--refresh] [--ignore-errors] [--ignore-unmatch] [--]
+	  <filepattern>...
 
 DESCRIPTION
 -----------
@@ -119,6 +120,9 @@ apply.
 	them, do not abort the operation, but continue adding the
 	others. The command shall still exit with non-zero status.
 
+--ignore-unmatch::
+	Exit with a zero status even if no files matched.
+
 \--::
 	This option can be used to separate command-line options from
 	the list of files, (useful when filenames might be mistaken
-- 
1.6.3.3

^ permalink raw reply related

* [RFC] Store subtree entries in the same hash map as the note entries
From: Johan Herland @ 2009-08-13  3:00 UTC (permalink / raw)
  To: Johannes Schindelin
  Cc: git, gitster, trast, tavestbo, git, chriscool, spearce
In-Reply-To: <200908010436.57480.johan@herland.net>

This is a first draft at implementing Dscho's idea of improving note parser
performance by storing the subtree entries in the same hash map as the note
entries.

In order to tell subtree entries and note entries apart, another member has
been added to struct entry: unsigned char commit_sha1_len. This member
stores the number of "valid" bytes in the commit_sha1 member, meaning that
a value of 1-19 indicates a subtree entry, and a value of 20 indicates a
note entry. There are two more special values for this new member as well:

- Since a null SHA1 is also a valid subtree entry (e.g. the "00/*" subtree
  in a 2/38 fanout scheme), we can no longer use is_null_sha1() to identify
  unused entries in the hash map. Instead, a value of 0 in the new
  commit_sha1_len member indicates that this is entry is null/unused.

  There is one exception to this rule: the root notes tree which is just a
  special case of a subtree entry with 0 "valid" bytes in the commit_sha1
  member. However, this exception is acceptable, as the root entry is never
  stored in the hash map (the hash map is initialized by unpacking this
  root tree entry).

- The second special commit_sha1_len value is 255, and is used to indicate
  a subtree entry that has already been unpacked, and should therefore be
  removed from the hash map. It is expensive and non-trivial to _delete_
  an entry in the hash map, and we therefore use this special value to
  _ignore_ the entry. If/when the hash map is grown/reallocated, we simply
  avoid bringing the unpacked subtree entries into the new hash map.

$ ./test_performance.sh
Timing 100 reps of 'git log -n 10 refs/heads/master >/dev/null' at fanout level 0...
21.80user 2.15system 0:24.12elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+1051886minor)pagefaults 0swaps

Timing 100 reps of 'git log -n 10 refs/heads/master >/dev/null' at fanout level 1...
1.24user 0.24system 0:01.49elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+120478minor)pagefaults 0swaps

Timing 100 reps of 'git log -n 10 refs/heads/master >/dev/null' at fanout level 2...
0.73user 0.20system 0:00.95elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+105782minor)pagefaults 0swaps

Signed-off-by: Johan Herland <johan@herland.net>
---

On Wednesday 29 July 2009, Johannes Schindelin wrote:
> I know you want to have something working first and optimize then, but I
> imagined that the hashmap can actually contain the entries of the partial
> hashes, too.  You'll need to extend the data type, of course, to be able
> to say just how many digits of the SHA-1 are valid, and I guess for
> consistency you'll need to pad with 0s.

Ok. Here's a draft implementation of your proposal to store the subtree
entries in the same hash map as the note entries.

This code is somewhat faster than my first subtree-in-linked-list draft,
but considerably slower than my 256-tree proposal:

                    fanout level 0   fanout level 1   fanout level 2
  subtree-in-ll         32.71s            1.88s            0.65s
  all-in-hash-map       24.12s            1.49s            0.95s
  all-in-256-tree       20.39s            1.06s            0.63s

I'm not sure how closely my implementation follows your vision, so please
suggest improvements, fixes, etc.


Have fun! :)

...Johan


 notes.c |  155 +++++++++++++++++++++++++--------------------------------------
 1 files changed, 62 insertions(+), 93 deletions(-)

diff --git a/notes.c b/notes.c
index 7e9dc49..34b8892 100644
--- a/notes.c
+++ b/notes.c
@@ -9,6 +9,15 @@
 struct entry {
 	unsigned char commit_sha1[20];
 	unsigned char notes_sha1[20];
+	/*
+	 * The following member can have the following values:
+	 * 0    - This is a NULL/blank entry in the hash_map
+	 *        (Exception: The root_tree entry in initialize_hash_map())
+	 * 1-19 - This is a subtree with the given number of valid prefix bytes
+	 * 20   - This is a note
+	 * 255  - This is a subtree which has been unpacked, please ignore
+	 */
+	unsigned char commit_sha1_len;
 };
 
 struct hash_map {
@@ -16,43 +25,35 @@ struct hash_map {
 	off_t count, size;
 };
 
-struct subtree_entry {
-	/*
-	 * SHA1 prefix is stored in the first 19 bytes (w/trailing NUL bytes);
-	 * length of SHA1 prefix is stored in the last byte
-	 */
-	unsigned char sha1_prefix_w_len[20];
-	unsigned char subtree_sha1[20];
-	struct subtree_entry *next;
-};
-
 static int initialized;
 static struct hash_map hash_map;
-static struct subtree_entry *subtree_list;
 
 static int hash_index(struct hash_map *map, const unsigned char *sha1)
 {
 	int i = ((*(unsigned int *)sha1) % map->size);
 
 	for (;;) {
-		unsigned char *current = map->entries[i].commit_sha1;
+		struct entry *current = &(map->entries[i]);
 
-		if (!hashcmp(sha1, current))
-			return i;
-
-		if (is_null_sha1(current))
+		if (!current->commit_sha1_len)
 			return -1 - i;
 
+		if (!hashcmp(sha1, current->commit_sha1)
+		 && current->commit_sha1_len <= 20)
+			return i;
+
 		if (++i == map->size)
 			i = 0;
 	}
 }
 
 static void add_entry(const unsigned char *commit_sha1,
-		const unsigned char *notes_sha1)
+		const unsigned char *notes_sha1,
+		unsigned char commit_sha1_len)
 {
 	int index;
 
+	assert(commit_sha1_len > 0 && commit_sha1_len <= 20);
 	if (hash_map.count + 1 > hash_map.size >> 1) {
 		int i, old_size = hash_map.size;
 		struct entry *old = hash_map.entries;
@@ -61,13 +62,20 @@ static void add_entry(const unsigned char *commit_sha1,
 		hash_map.entries = (struct entry *)
 			xcalloc(sizeof(struct entry), hash_map.size);
 
-		for (i = 0; i < old_size; i++)
-			if (!is_null_sha1(old[i].commit_sha1)) {
+		for (i = 0; i < old_size; i++) {
+			switch (old[i].commit_sha1_len) {
+			case 255:
+				hash_map.count--;
+				/* fall through */
+			case 0:
+				continue;
+			default:
 				index = -1 - hash_index(&hash_map,
 						old[i].commit_sha1);
 				memcpy(hash_map.entries + index, old + i,
 					sizeof(struct entry));
 			}
+		}
 		free(old);
 	}
 
@@ -79,6 +87,7 @@ static void add_entry(const unsigned char *commit_sha1,
 
 	hashcpy(hash_map.entries[index].commit_sha1, commit_sha1);
 	hashcpy(hash_map.entries[index].notes_sha1, notes_sha1);
+	hash_map.entries[index].commit_sha1_len = commit_sha1_len;
 }
 
 /*
@@ -110,22 +119,26 @@ static int get_sha1_hex_segment(const char *hex, unsigned int hex_len,
 	return len;
 }
 
-static void load_subtree(struct subtree_entry *se)
+static void load_subtree(struct entry *subtree)
 {
 	unsigned char commit_sha1[20];
 	unsigned int prefix_len;
 	void *buf;
 	struct tree_desc desc;
 	struct name_entry entry;
-	struct subtree_entry *tmp_list = NULL, *tmp_last = NULL;
 
-	buf = fill_tree_descriptor(&desc, se->subtree_sha1);
+	buf = fill_tree_descriptor(&desc, subtree->notes_sha1);
 	if (!buf)
 		die("Could not read %s for notes-index",
-		     sha1_to_hex(se->subtree_sha1));
+		     sha1_to_hex(subtree->notes_sha1));
+
+	prefix_len = subtree->commit_sha1_len;
+	assert(prefix_len < 20);
+	memcpy(commit_sha1, subtree->commit_sha1, prefix_len);
+
+	/* Invalidate this subtree from further consideration */
+	subtree->commit_sha1_len = 255;
 
-	prefix_len = se->sha1_prefix_w_len[19];
-	memcpy(commit_sha1, se->sha1_prefix_w_len, prefix_len);
 	while (tree_entry(&desc, &entry)) {
 		int len = get_sha1_hex_segment(entry.path, strlen(entry.path),
 				commit_sha1 + prefix_len, 20 - prefix_len);
@@ -133,110 +146,66 @@ static void load_subtree(struct subtree_entry *se)
 			continue; /* entry.path is not a SHA1 sum. Skip */
 		len += prefix_len;
 
-		/* If commit SHA1 is complete, assume note object */
-		if (len == 20)
-			add_entry(commit_sha1, entry.sha1);
-		/* If commit SHA1 is incomplete, assume note subtree */
-		else if (len < 20 && entry.mode == S_IFDIR) {
-			struct subtree_entry *n = (struct subtree_entry *)
-				xcalloc(sizeof(struct subtree_entry), 1);
-			hashcpy(n->sha1_prefix_w_len, commit_sha1);
-			n->sha1_prefix_w_len[19] = (unsigned char) len;
-			hashcpy(n->subtree_sha1, entry.sha1);
-
-			if (!tmp_list) {
-				tmp_list = n;
-				tmp_last = n;
-			}
-			else {
-				assert(!tmp_last->next);
-				assert(hashcmp(n->sha1_prefix_w_len,
-					tmp_last->sha1_prefix_w_len) > 0);
-				tmp_last->next = n;
-				tmp_last = n;
-			}
-		}
+		if (len == 20 || (len < 20 && entry.mode == S_IFDIR))
+			add_entry(commit_sha1, entry.sha1, len);
 	}
 	free(buf);
-	if (tmp_list) {
-		/* insert tmp_list immediately after se */
-		assert(hashcmp(tmp_list->sha1_prefix_w_len,
-				se->sha1_prefix_w_len) > 0);
-		if (se->next) {
-			assert(hashcmp(se->next->sha1_prefix_w_len,
-					tmp_last->sha1_prefix_w_len) > 0);
-			tmp_last->next = se->next;
-		}
-		se->next = tmp_list;
-	}
 }
 
 static void initialize_hash_map(const char *notes_ref_name)
 {
 	unsigned char sha1[20], commit_sha1[20];
 	unsigned mode;
-	struct subtree_entry root_tree;
+	struct entry root_tree;
 
 	if (!notes_ref_name || read_ref(notes_ref_name, commit_sha1) ||
 	    get_tree_entry(commit_sha1, "", sha1, &mode))
 		return;
 
-	hashclr(root_tree.sha1_prefix_w_len);
-	hashcpy(root_tree.subtree_sha1, sha1);
-	root_tree.next = NULL;
+	hashclr(root_tree.commit_sha1);
+	hashcpy(root_tree.notes_sha1, sha1);
+	root_tree.commit_sha1_len = 0;
 	load_subtree(&root_tree);
-	subtree_list = root_tree.next;
 }
 
-/*
- * Compare the given commit SHA1 against the given subtree entry.
- * Return -1 if the commit SHA1 cannot exist within the given subtree, or any
- * subtree following it.
- * Return 0 if the commit SHA1 _may_ exist within the given subtree.
- * Return 1 if the commit SHA1 cannot exist within the given subtree, but may
- * exist within a subtree following it.
- */
-static int commit_subtree_cmp(const unsigned char *commit_sha1,
-		const struct subtree_entry *entry)
+static struct entry *lookup_subtree(const unsigned char *commit_sha1)
 {
-	unsigned int prefix_len = entry->sha1_prefix_w_len[19];
-	return memcmp(commit_sha1, entry->sha1_prefix_w_len, prefix_len);
-}
+	unsigned char prefix_sha1[20];
+	unsigned char i;
+	int index;
 
-static struct subtree_entry *lookup_subtree(const unsigned char *commit_sha1)
-{
-	struct subtree_entry *found = NULL, *cur = subtree_list;
-	while (cur) {
-		int cmp = commit_subtree_cmp(commit_sha1, cur);
-		if (!cmp)
-			found = cur;
-		if (cmp < 0)
-			break;
-		cur = cur->next;
+	hashcpy(prefix_sha1, commit_sha1);
+	for (i = 19; i; --i) {
+		prefix_sha1[i] = 0;
+		index = hash_index(&hash_map, prefix_sha1);
+		if (index >= 0 && hash_map.entries[index].commit_sha1_len == i)
+			return &(hash_map.entries[index]);
 	}
-	return found;
+	return NULL;
 }
 
 static unsigned char *lookup_notes(const unsigned char *commit_sha1)
 {
 	int index;
-	struct subtree_entry *subtree;
+	struct entry *subtree;
+
+	if (!hash_map.size)
+		return NULL;
 
 	/* First, try to find the commit SHA1 directly in hash map */
-	index = hash_map.size ? hash_index(&hash_map, commit_sha1) : -1;
+	index = hash_index(&hash_map, commit_sha1);
 	if (index >= 0)
 		return hash_map.entries[index].notes_sha1;
 
 	/* Next, try finding a subtree that may contain the commit SHA1 */
 	subtree = lookup_subtree(commit_sha1);
 
-	/* Give up if no subtree found, or if subtree is already loaded */
-	if (!subtree || is_null_sha1(subtree->subtree_sha1))
+	/* Give up if no subtree found */
+	if (!subtree)
 		return NULL;
 
 	/* Load subtree into hash_map, and retry lookup recursively */
 	load_subtree(subtree);
-	hashclr(subtree->subtree_sha1);
 	return lookup_notes(commit_sha1);
 }
 
-- 
1.6.4.rc3.138.ga6b98.dirty

^ permalink raw reply related

* Re: fatal: bad revision 'HEAD'
From: Jeff King @ 2009-08-13  2:31 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Joel Mahoney, Johannes Schindelin, git
In-Reply-To: <7vab24ve97.fsf@alter.siamese.dyndns.org>

On Wed, Aug 12, 2009 at 03:49:56PM -0700, Junio C Hamano wrote:

> When doing a "pull --rebase", we check to make sure that the index and
> working tree are clean. The index-clean check compares the index against
> HEAD. The test erroneously reports dirtiness if we don't have a HEAD yet.
> 
> In such an "unborn branch" case, by definition, a non-empty index won't
> be based on whatever we are pulling down from the remote, and will lose
> the local change.  Just check if $GIT_DIR/index exists and error out.
> 
> Signed-off-by: Jeff King <peff@peff.net>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Looks sane to me, but see below.

> +		# On an unborn branch
> +		if test -f "$GIT_DIR/index"
> +		then
> +			die "updating an unborn branch with changes added to the index"
> +		fi

I had a brief moment where I thought this might not actually be
sufficient. That is, can somebody create an unborn branch in an existing
repo (e.g., because they want an alternate project root) in such a way
that they have an index, but it is empty? In which case we should be
actually checking for index emptiness instead of existence.

I.e., I have done in the past (but not frequently):

  git symbolic-ref HEAD refs/heads/to-be-born

in an existing repository to create a new root. But I don't think we
really need to worry about that case:

  1. It is somewhat crazy and rare in the first place. Even more crazy
     and rare would be to "git pull --rebase" immediately afterwards.

  2. If you _did_ have an index, either:

     2a. You want to keep it, in which case your check is sane.

     2b. You want to start fresh, in which case your next step would be
         be "rm -f .git/index".

The only way this check would not be OK is is if you did something like:

  git symbolic-ref HEAD refs/heads/new-branch
  git ls-files | xargs git rm --cached
  git pull --rebase ...

which just seems crazy.

So I think I have convinced myself that what you have is fine, but I
just wanted a sanity check.

-Peff

^ permalink raw reply

* What's cooking in git.git (Aug 2009, #02; Wed, 12)
From: Junio C Hamano @ 2009-08-13  2:14 UTC (permalink / raw)
  To: git

Here are the topics that have been cooking.  Commits prefixed with '-' are
only in 'pu' while commits prefixed with '+' are in 'next'.  The ones
marked with '.' do not appear in any of the branches, but I am still
holding onto them.

After the 1.6.5 cycle, the next release will be 1.7.0, and we will push
out the planned "push safety" change.  1.7.0 would be a good time to
introduce "justifiable" changes that are not strictly backward compatible.

During 1.6.5 cycle, 'next' will hold topics meant for 1.6.5 and 1.7.0.

----------------------------------------------------------------
[New Topics]

* ld/p4 (Thu Jul 30 00:13:46 2009 +0100) 1 commit
 - git-p4: stream from perforce to speed up clones

Waiting for Ack/Nack from stakeholders.  Probably I should merge this to
'next' soon, keep it there for a week and see if anybody screams, aka
"Nack now or forever hold your peace" ;-).

* mr/gitweb-xz (Thu Aug 6 10:28:25 2009 -0400) 3 commits
 - gitweb: add support for XZ compressed snapshots
 - gitweb: update INSTALL regarding specific snapshot settings
 - gitweb: support to globally disable a snapshot format

This should be safe as long as it does not silently enable itself for
folks who merely updated gitweb to this version without explicitly asking
for the new format (but I do not remember if that is what the patch does).

* jh/cvs-helper (Wed Aug 12 02:13:51 2009 +0200) 4 commits
 - Add simple selftests of git-remote-cvs functionality
 - Third draft of CVS remote helper program
 - Add Python support library for CVS remote helper
 - Basic build infrastructure for Python scripts

Builds on db/vcs-helper.  The last round failed its own selftest for me,
but this one seems to be Ok.  Documentation/git-remote-cvs.txt needs to be
fixed to build, though.

* bc/maint-am-email (Thu Aug 6 20:08:13 2009 -0500) 2 commits
 + git-am: print fair error message when format detection fails
 + am: allow individual e-mail files as input

It seems that the "not mbox but a single piece of e-mail" format was
something many people relied on.  I'm cooking this in 'next', and
hopefully it can graduate both to 'master' and 'maint'.

* js/maint-cover-letter-non-ascii (Mon Aug 10 18:22:22 2009 +0200) 2 commits
 + Correctly mark cover letters' encodings if they are not pure ASCII
 + Expose the has_non_ascii() function

* jc/verify-pack-stat (Fri Aug 7 15:45:30 2009 -0700) 2 commits
 + verify-pack --stat-only: show histogram without verifying
 + Merge branch 'maint' into jc/verify-pack-stat

* lt/block-sha1 (Wed Aug 12 15:47:55 2009 -0400) 15 commits
 + block-sha1: support for architectures with memory alignment
   restrictions
 + block-sha1: split the different "hacks" to be individually
   selected
 + block-sha1: move code around
 + block-sha1: improve code on large-register-set machines
 + block-sha1: improved SHA1 hashing
 + block-sha1: perform register rotation using cpp
 + block-sha1: get rid of redundant 'lenW' context
 + block-sha1: Use '(B&C)+(D&(B^C))' instead of '(B&C)|(D&(B|C))' in
   round 3
 + block-sha1: macroize the rounds a bit further
 + block-sha1: re-use the temporary array as we calculate the SHA1
 + block-sha1: make the 'ntohl()' part of the first SHA1 loop
 + block-sha1: minor fixups
 + block-sha1: try to use rol/ror appropriately
 + block-sha1: undo ctx->size change
 + Add new optimized C 'block-sha1' routines

Linus's "written in C, faster than handcrafted asm" SHA-1 implementation
with clean-up and ARM support from Nico.

* nd/sparse (Tue Aug 11 22:44:06 2009 +0700) 8 commits
 . --sparse for porcelains
 . Support sparse checkout in unpack_trees() and read-tree
 . unpack-trees.c: generalize verify_* functions
 . dir.c: export excluded_1() and add_excludes_from_file_1()
 . excluded_1(): support exclude "directories" in index
 . Read .gitignore from index if it is assume-unchanged
 . Avoid writing to buffer in add_excludes_from_file_1()
 . Prevent diff machinery from examining assume-unchanged entries on
   worktree

Privately applied but not yet queued to 'pu', expecting a minor reroll
near the tip.

* jk/maint-merge-msg-fix (Sun Aug 9 06:02:51 2009 -0400) 3 commits
 + merge: indicate remote tracking branches in merge message
 + merge: fix incorrect merge message for ambiguous tag/branch
 + add tests for merge message headings

----------------------------------------------------------------
[Graduated to "master"]

* zf/maint-gitweb-acname (Sun Aug 2 09:42:24 2009 +0200) 1 commit
 - gitweb: parse_commit_text encoding fix

* jc/maint-merge-recursive-fix (Thu Jul 30 17:38:15 2009 -0700) 1 commit
 - merge-recursive: don't segfault while handling rename clashes

* js/run-command-updates (Tue Aug 4 11:28:40 2009 +0200) 7 commits
 + run-command.c: squelch a "use before assignment" warning
 + receive-pack: remove unnecessary run_status report
 + run_command: report failure to execute the program, but optionally
   don't
 + run_command: encode deadly signal number in the return value
 + run_command: report system call errors instead of returning error
   codes
 + run_command: return exit code as positive value
 + MinGW: simplify waitpid() emulation macros

* mk/grep-max-depth (Wed Jul 22 19:52:15 2009 +0200) 1 commit
 + grep: Add --max-depth option.

* jp/symlink-dirs (Wed Jul 29 20:22:25 2009 -0700) 3 commits
 + git-checkout: be careful about untracked symlinks
 + lstat_cache: guard against full match of length of 'name'
   parameter
 + Demonstrate bugs when a directory is replaced with a symlink

----------------------------------------------------------------
[In 'next']

* bc/mailsplit-cr-at-eol (Tue Aug 4 22:31:59 2009 -0500) 4 commits
 + Allow mailsplit (and hence git-am) to handle mails with CRLF line-
   endings
 + builtin-mailsplit.c: remove read_line_with_nul() since it is no
   longer used
 + builtin-mailinfo,builtin-mailsplit: use strbufs
 + strbuf: add new function strbuf_getwholeline()

* gb/apply-ignore-whitespace (Tue Aug 4 13:16:49 2009 +0200) 1 commit
 + git apply: option to ignore whitespace differences

* cc/replace (Wed May 27 07:14:09 2009 +0200) 14 commits
 + t6050: check pushing something based on a replaced commit
 + Documentation: add documentation for "git replace"
 + Add git-replace to .gitignore
 + builtin-replace: use "usage_msg_opt" to give better error messages
 + parse-options: add new function "usage_msg_opt"
 + builtin-replace: teach "git replace" to actually replace
 + Add new "git replace" command
 + environment: add global variable to disable replacement
 + mktag: call "check_sha1_signature" with the replacement sha1
 + replace_object: add a test case
 + object: call "check_sha1_signature" with the replacement sha1
 + sha1_file: add a "read_sha1_file_repl" function
 + replace_object: add mechanism to replace objects found in
   "refs/replace/"
 + refs: add a "for_each_replace_ref" function

* jc/1.7.0-diff-whitespace-only-status (Sat May 23 01:15:35 2009 -0700) 2 commits
 + diff: Rename QUIET internal option to QUICK
 + diff: change semantics of "ignore whitespace" options

This changes exit code from "git diff --ignore-whitespace" and friends
when there is no actual output.  It is a backward incompatible change, but
we could argue that it is a bugfix.

* jc/1.7.0-push-safety (Mon Feb 9 00:19:46 2009 -0800) 2 commits
 + Refuse deleting the current branch via push
 + Refuse updating the current branch in a non-bare repository via
   push

----------------------------------------------------------------
[In 'pu']

* jn/gitweb-blame (Thu Aug 6 19:11:52 2009 +0200) 14 commits
 - gitweb: Create links leading to 'blame_incremental' using
   JavaScript
 - gitweb: Incremental blame (proof of concept)
 - gitweb: Add optional "time to generate page" info in footer
 + Revert the four topmost commits from jn/gitweb-blame topic
 + gitweb: Create links leading to 'blame_incremental' using
   JavaScript
 + gitweb: Incremental blame (proof of concept)
 + gitweb: Add optional "time to generate page" info in footer
 + gitweb: Add -partial_query option to href() subroutine
 + gitweb: Use light/dark for class names also in 'blame' view
 + gitweb: Add author initials in 'blame' view, a la "git gui blame"
 + gitweb: Mark commits with no "previous" in 'blame' view
 + gitweb: Use "previous" header of git-blame -p in 'blame' view
 + gitweb: Mark boundary commits in 'blame' view
 + gitweb: Make .error style generic

I haven't picked up Jakub's replacement to the second one from the tip.
We probably should merge up to "Use light/dark" (aef3768) to 'master' and
start the rest over.

* jc/maint-clean-nested-dir-safety (Tue Jun 30 15:33:45 2009 -0700) 1 commit
 + clean: require double -f options to nuke nested git repository and
   work tree

This probably should go in 'master' soonish.

* jc/shortstatus (Tue Aug 4 23:55:22 2009 -0700) 12 commits
 - git stat -s: short status output
 - git stat: pathspec limits, unlike traditional "git status"
 - git stat: the beginning
 + wt-status: collect untracked files in a separate "collect" phase
 + Make git_status_config() file scope static to builtin-commit.c
 + wt-status: move wt_status_colors[] into wt_status structure
 + wt-status: move many global settings to wt_status structure
 + commit: --dry-run
 + status: show worktree status of conflicted paths separately
 + wt-status.c: rework the way changes to the index and work tree are
   summarized
 + diff-index: keep the original index intact
 + diff-index: report unmerged new entries

Slowly progressing.  I've addressed issues pointed out by Jeff in his
review, and hopefully the whole thing would be ready to go.

* db/vcs-helper (Sun Aug 9 15:28:28 2009 -0400) 17 commits
 - Allow helpers to request marks for fast-import
 - Allow helpers to report in "list" command that the ref is
   unchanged
 - Add support for "import" helper command
 - transport-helper_init(): fix a memory leak in error path
 - Add a config option for remotes to specify a foreign vcs
 - Allow programs to not depend on remotes having urls
 - Allow fetch to modify refs
 - Use a function to determine whether a remote is valid
 - Use a clearer style to issue commands to remote helpers
 + Makefile: install hardlinks for git-remote-<scheme> supported by
   libcurl if possible
 + Makefile: do not link three copies of git-remote-* programs
 + Makefile: git-http-fetch does not need expat
 + http-fetch: Fix Makefile dependancies
 + Add transport native helper executables to .gitignore
 + git-http-fetch: not a builtin
 + Use an external program to implement fetching with curl
 + Add support for external programs for handling native fetches

This consolidates various previous rounds from Daniel and Johan.  It seems
that the use of colon ':' before vcs helper name needs to be corrected
before this series can go further.

* je/send-email-no-subject (Wed Aug 5 18:49:54 2009 +0200) 1 commit
 - send-email: confirm on empty mail subjects

This seems to break t9001.  Near the tip of 'pu' I have a iffy workaround.

* jh/notes (Wed Jul 29 04:25:26 2009 +0200) 8 commits
 - t3302-notes-index-expensive: Speed up create_repo()
 - fast-import: Add support for importing commit notes
 - First draft of notes tree parser with support for fanout subtrees
 - Teach "-m <msg>" and "-F <file>" to "git notes edit"
 - Add an expensive test for git-notes
 - Speed up git notes lookup
 - Add a script to edit/inspect notes
 - Introduce commit notes

* cc/sequencer-rebase-i (Wed Aug 5 22:53:00 2009 +0200) 8 commits
 - rebase -i: use "git sequencer--helper --reset-hard"
 - sequencer: add "--reset-hard" option to "git sequencer--helper"
 - sequencer: add comments about reset_almost_hard()
 - sequencer: add "reset_almost_hard()" and related functions
 - rebase -i: use "git sequencer--helper --make-patch"
 - sequencer: free memory used in "make_patch" function
 - sequencer: add "make_patch" function to save a patch
 - sequencer: add "builtin-sequencer--helper.c"

More sequencer updates.  I didn't look at the latest round that had a
handful "oops, fix that earlier botch" patches, expecting a cleaner
reroll.

* jc/mailinfo-remove-brackets (Wed Jul 15 15:31:12 2009 -0700) 1 commit
 - mailinfo: -b option keeps [bracketed] strings that is not a
   [PATCH] marker

* tr/reset-checkout-patch (Tue Jul 28 23:20:12 2009 +0200) 8 commits
 - DWIM 'git stash save -p' for 'git stash -p'
 - Merge branch 'js/stash-dwim' into tr/reset-checkout-patch
 - Make 'git stash -k' a short form for 'git stash save --keep-index'
 - Implement 'git stash save --patch'
 - Implement 'git checkout --patch'
 - Implement 'git reset --patch'
 - builtin-add: refactor the meat of interactive_add()
 - git-apply--interactive: Refactor patch mode code

Progress?

* js/stash-dwim (Mon Jul 27 20:37:10 2009 +0200) 1 commit
 - Make 'git stash -k' a short form for 'git stash save --keep-index'

This should be merged to 'next' soonish, but I keep forgetting.

* pb/tracking (Thu Jul 16 16:26:15 2009 -0500) 7 commits
 . branch.c: if remote is not config'd for branch, don't try delete
   push config
 . branch, checkout: introduce autosetuppush
 . move deletion of merge configuration to branch.c
 . remote: add per-remote autosetupmerge and autosetuprebase
   configuration
 . introduce a struct tracking_config
 . branch: install_branch_config and struct tracking refactoring
 . config: allow false and true values for branch.autosetuprebase

Has been ejected from 'pu' for some time, expecting a reroll.

* jc/log-tz (Tue Mar 3 00:45:37 2009 -0800) 1 commit
 - Allow --date=local --date=other-format to work as expected

^ permalink raw reply

* Re: [RFCv3 2/4] Add Python support library for CVS remote helper
From: Johan Herland @ 2009-08-13  1:27 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: David Aguilar, git, barkalow, Johannes.Schindelin
In-Reply-To: <7vzla4r0qc.fsf@alter.siamese.dyndns.org>

On Thursday 13 August 2009, Junio C Hamano wrote:
> David Aguilar <davvid@gmail.com> writes:
> > This also had me wondering about the following:
> > 	git uses tabs for indentation
>
> Not relevant.  That is a rule for our "C" source code.  We also use it in
> our Perl scripts and shell scripts because there is no single "one right
> way" that is strongly defined and everybody adheres to, like the 4-space
> rule Python folks have.
>
> > BUT, the python convention is to use 4-space indents ala PEP-8
> > http://www.python.org/dev/peps/pep-0008/
> >
> > It might be appealing to when-in-Rome (Rome being Python) here
> > and do things the python way when we code in Python.
>
> Yes, this is more important.
>
> >> +		if len(msg) > 25: msg = msg[:22] + "..." # Max 25 chars long
> >> +		return "<Changeset @(%s) by %s (%s) updating %i files>" % (
> >> +			self.date, self.author, msg, len(self.revs))
> >
> > Similar to the git coding style, this might be better written:
>
> So is this one.  If experienced Python folks also frown on single-line
> conditionals, then by all means please update this.  But if this
> suggestion is solely because we don't do a single-line conditional in our
> C source code, then please do not insist on it too strongly.  The code
> should look familiar to Pythonistas with good tastes (if such a class of
> people exist, that is ;-)).

Ok. Thanks. I will follow PEP8 as closely as possible, including the 4-space 
indent.


...Johan

-- 
Johan Herland, <johan@herland.net>
www.herland.net

^ permalink raw reply

* Re: [RFCv3 2/4] Add Python support library for CVS remote helper
From: Junio C Hamano @ 2009-08-13  0:55 UTC (permalink / raw)
  To: David Aguilar; +Cc: Johan Herland, git, barkalow, Johannes.Schindelin
In-Reply-To: <20090812021017.GB62301@gmail.com>

David Aguilar <davvid@gmail.com> writes:

> This also had me wondering about the following:
> 	git uses tabs for indentation

Not relevant.  That is a rule for our "C" source code.  We also use it in
our Perl scripts and shell scripts because there is no single "one right
way" that is strongly defined and everybody adheres to, like the 4-space
rule Python folks have.

> BUT, the python convention is to use 4-space indents ala PEP-8
> http://www.python.org/dev/peps/pep-0008/
>
> It might be appealing to when-in-Rome (Rome being Python) here
> and do things the python way when we code in Python.

Yes, this is more important.

>> +		if len(msg) > 25: msg = msg[:22] + "..." # Max 25 chars long
>> +		return "<Changeset @(%s) by %s (%s) updating %i files>" % (
>> +			self.date, self.author, msg, len(self.revs))
>
> Similar to the git coding style, this might be better written:

So is this one.  If experienced Python folks also frown on single-line
conditionals, then by all means please update this.  But if this
suggestion is solely because we don't do a single-line conditional in our
C source code, then please do not insist on it too strongly.  The code
should look familiar to Pythonistas with good tastes (if such a class of
people exist, that is ;-)).

^ permalink raw reply

* Re: [PATCH] svn: Add && to t9107-git-svn-migrarte.sh
From: Adam Brewster @ 2009-08-13  0:35 UTC (permalink / raw)
  To: Eric Wong; +Cc: git
In-Reply-To: <20090812094940.GA22273@dcvr.yhbt.net>

Eric,

Thanks the help in getting this right.

> I think the following change on top of yours would make most
> sense:
>

Looks good to me.

> The map_path() changes you originally made didn't work, either, since
> the -f $1 never took GIT_DIR or GIT_DIR/svn into account.
>

It was ugly, too.

> I think the below is a good enough test case to for compatibility
> against existing repos.  Let me know what you think, thanks!
>

Looks about right.

Thanks,
Adam

^ permalink raw reply

* Re: GCC Git mirror no longer updating
From: Bernie Innocenti @ 2009-08-13  0:28 UTC (permalink / raw)
  To: Jason Merrill; +Cc: Daniel Berlin, Frank Ch. Eigler, overseers, git
In-Reply-To: <4A82C786.5060602@redhat.com>

El Wed, 12-08-2009 a las 09:45 -0400, Jason Merrill escribió:
> On 08/12/2009 06:56 AM, Bernie Innocenti wrote:
> > The git repository format should support concurrent access, but perhaps
> > it only applies to git-receive-pack, not fancy operations such as
> > repacking.
> 
> The git repository format, yes, but maybe not the stuff in .git/svn.  It 
> seems like a temporary index file was referring to an object that got 
> garbage collected away.  Or maybe the index file was left over from the 
> initial import, and not there due to a collision; there don't seem to be 
> index files there normally.

git-svn might be keeping extra information in files that the other git
tools don't know about.  This would explain why some objects looked
like orphans and were thus culled.  [cc'ing the git list to catch the
attention of the git-svn maintainer(s)].

Ah, and I just fixed a problem I have introduced myself while fiddling
to recover the repository: HEAD should point at "refs/remotes/trunk",
otherwise new commits won't show up in gitweb.

-- 
   // Bernie Innocenti - http://codewiz.org/
 \X/  Sugar Labs       - http://sugarlabs.org/

^ permalink raw reply

* Re: [RFCv3 2/4] Add Python support library for CVS remote helper
From: Johan Herland @ 2009-08-13  0:20 UTC (permalink / raw)
  To: Michael Haggerty
  Cc: David Aguilar, git, barkalow, gitster, Johannes.Schindelin,
	Sverre Rabbelier
In-Reply-To: <4A83579E.70302@alum.mit.edu>

On Thursday 13 August 2009, Michael Haggerty wrote:
> Johan Herland wrote:
> > On Wednesday 12 August 2009, David Aguilar wrote:
> >> On Wed, Aug 12, 2009 at 02:13:49AM +0200, Johan Herland wrote:
> >>> +	def __init__ (self, date, author, message):
> >>> +		self.revs    = {}      # dict: path -> CvsRev object
> >>> +		self.date    = date    # CvsDate object
> >>> +		self.author  = author
> >>> +		self.message = message # Lines of commit message
> >>
> >> pep8 and other parts of the git codebase recommend against
> >> lining up the equals signs like that.  Ya, sorry for the nits
> >> being that they're purely stylistic.
> >
> > I can't find a good rationale for this rule in PEP8 (other than Guido's
> > personal style), and I personally find the above much more readable
> > (otherwise I wouldn't go through the trouble of lining them all up...).
> > Can I claim exception (1) (readability)?
>
> I think you are missing the point.  It may be true that the rules in
> PEP8 were *originally* written according to the unjustified whims of the
> BDFL, but now that they are established the reason for following them is
> not that Guido likes them but rather to be consistent with the bulk of
> other Python code on the planet.

Ok. I will try to follow PEP8 as closely as possible.

> With respect to the rule to use 4-space indents, there are serious
> practical problems with using tabs *in addition to* the consistency
> argument.

There are? What arguments? Assuming I don't mix spaces and tabs (which I 
certainly don't), I can't see any "practical problems" with using tabs 
(except for the PEP8/consistency issue).


...Johan

-- 
Johan Herland, <johan@herland.net>
www.herland.net

^ permalink raw reply

* Re: [RFCv3 2/4] Add Python support library for CVS remote helper
From: Michael Haggerty @ 2009-08-13  0:00 UTC (permalink / raw)
  To: Johan Herland; +Cc: David Aguilar, git, barkalow, gitster, Johannes.Schindelin
In-Reply-To: <200908121108.28714.johan@herland.net>

Johan Herland wrote:
> On Wednesday 12 August 2009, David Aguilar wrote:
>> On Wed, Aug 12, 2009 at 02:13:49AM +0200, Johan Herland wrote:
>>> +	def __init__ (self, date, author, message):
>>> +		self.revs    = {}      # dict: path -> CvsRev object
>>> +		self.date    = date    # CvsDate object
>>> +		self.author  = author
>>> +		self.message = message # Lines of commit message
>> pep8 and other parts of the git codebase recommend against
>> lining up the equals signs like that.  Ya, sorry for the nits
>> being that they're purely stylistic.
> 
> I can't find a good rationale for this rule in PEP8 (other than Guido's 
> personal style), and I personally find the above much more readable 
> (otherwise I wouldn't go through the trouble of lining them all up...). Can 
> I claim exception (1) (readability)?

I think you are missing the point.  It may be true that the rules in
PEP8 were *originally* written according to the unjustified whims of the
BDFL, but now that they are established the reason for following them is
not that Guido likes them but rather to be consistent with the bulk of
other Python code on the planet.

With respect to the rule to use 4-space indents, there are serious
practical problems with using tabs *in addition to* the consistency
argument.

Michael

^ permalink raw reply

* Re: [RFC/PATCH 2/6] transport_get(): Don't SEGFAULT on missing url
From: Johan Herland @ 2009-08-12 23:39 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, barkalow, benji, Johannes.Schindelin
In-Reply-To: <7vab24wtzo.fsf@alter.siamese.dyndns.org>

On Thursday 13 August 2009, Junio C Hamano wrote:
> Johan Herland <johan@herland.net> writes:
> > Signed-off-by: Johan Herland <johan@herland.net>
>
> How does url end up to be NULL?  At the beginning of transport_get(), you
> do this:
>
> 	ret->remote = remote;
> 	if (!url && remote && remote->url)
> 		url = remote->url[0];
> 	ret->url = url;
> 	if (remote && remote->foreign_vcs) {
> 		transport_helper_init(ret);
> 		return ret;
> 	}
>
> and the case where remote.$name.vcs is defined, we do not need
> remote.$name.url.
>
> When (!url && remote && remote->url), is remote->url[0] allowed to be
> NULL?  I am guessing it would be a bug in whoever prepared the remote,
> and if that is indeed the case, the patch shifts the symptoms without
> fixing the cause.
>
> When (remote && remote->foreign_vcs) does not hold, iow, if no remote is
> defined or the remote is defined but lacks remote.$name.url, you will go
> to the last else clause in the function that sets up a git_transport_data
> for the native transport, but it has ret->url == NULL.
>
> Whom does that transport talk with?  Is such a transport of any use, or
> does it cause a segfault downstream in the call chain?
>
> In other words, I am wondering if this patch should just diagnose the
> case as an error, instead of pretending all is well.

You are right. Instead of pushing the segfault downstream, we should verify 
that the url is non-NULL before returning it as part of ret (modulo the 
foreign case, of course).


...Johan

-- 
Johan Herland, <johan@herland.net>
www.herland.net

^ permalink raw reply

* Re: For review: git add --ignore-unmatch
From: Thomas Rast @ 2009-08-12 22:57 UTC (permalink / raw)
  To: Luke-Jr; +Cc: git
In-Reply-To: <200908121726.52121.luke-jr@utopios.org>

Luke-Jr wrote:
> 
> [0001-port-ignore-unmatch-from-git-rm-to-git-add.patch]
> [0002-fix-git-add-ignore-errors-to-ignore-pathspec-errors.patch]
> [0003-Document-ignore-unmatch-in-git-add.txt.patch]

I've already told you on IRC how to go about this, so please:

* send one patch per mail, inline
* write real commit messages
* sign off
* write tests

[Yeah, I'm tired and grumpy, but I'm also trying to save others the
work of saying this again more politely...]

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

^ permalink raw reply

* Re: fatal: bad revision 'HEAD'
From: Junio C Hamano @ 2009-08-12 22:49 UTC (permalink / raw)
  To: Jeff King; +Cc: Joel Mahoney, Johannes Schindelin, git
In-Reply-To: <20090812075833.GF15152@coredump.intra.peff.net>

Jeff King <peff@peff.net> writes:

> Yeah, I think that is a better idea. Do you want to tweak the patch, or
> should I re-submit?

I'll do this then.

-- >8 --
From: Jeff King <peff@peff.net>
Date: Tue, 11 Aug 2009 23:27:40 -0400
Subject: [PATCH] Subject: [PATCH] allow pull --rebase on branch yet to be born

When doing a "pull --rebase", we check to make sure that the index and
working tree are clean. The index-clean check compares the index against
HEAD. The test erroneously reports dirtiness if we don't have a HEAD yet.

In such an "unborn branch" case, by definition, a non-empty index won't
be based on whatever we are pulling down from the remote, and will lose
the local change.  Just check if $GIT_DIR/index exists and error out.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 git-pull.sh     |   18 +++++++++++++-----
 t/t5520-pull.sh |   11 +++++++++++
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/git-pull.sh b/git-pull.sh
index 0f24182..0bbd5bf 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -119,11 +119,19 @@ error_on_no_merge_candidates () {
 }
 
 test true = "$rebase" && {
-	git update-index --ignore-submodules --refresh &&
-	git diff-files --ignore-submodules --quiet &&
-	git diff-index --ignore-submodules --cached --quiet HEAD -- ||
-	die "refusing to pull with rebase: your working tree is not up-to-date"
-
+	if ! git rev-parse -q --verify HEAD >/dev/null
+	then
+		# On an unborn branch
+		if test -f "$GIT_DIR/index"
+		then
+			die "updating an unborn branch with changes added to the index"
+		fi
+	else
+		git update-index --ignore-submodules --refresh &&
+		git diff-files --ignore-submodules --quiet &&
+		git diff-index --ignore-submodules --cached --quiet HEAD -- ||
+		die "refusing to pull with rebase: your working tree is not up-to-date"
+	fi
 	oldremoteref= &&
 	. git-parse-remote &&
 	remoteref="$(get_remote_merge_branch "$@" 2>/dev/null)" &&
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index e78d402..dd2ee84 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -149,4 +149,15 @@ test_expect_success 'pull --rebase dies early with dirty working directory' '
 
 '
 
+test_expect_success 'pull --rebase works on branch yet to be born' '
+	git rev-parse master >expect &&
+	mkdir empty_repo &&
+	(cd empty_repo &&
+	 git init &&
+	 git pull --rebase .. master &&
+	 git rev-parse HEAD >../actual
+	) &&
+	test_cmp expect actual
+'
+
 test_done
-- 
1.6.4.196.gd1fd8

^ permalink raw reply related

* Re: [PATCH] Change mentions of "git programs" to "git commands"
From: Junio C Hamano @ 2009-08-12 22:39 UTC (permalink / raw)
  To: Nanako Shiraishi; +Cc: git, Ori Avtalion
In-Reply-To: <20090811125813.6117@nanako3.lavabit.com>

Nanako Shiraishi <nanako3@lavabit.com> writes:

>  I copy-edited Ori's patch for your convenience, and tried to clarify
>  the criteria you used to decide which "program" should become "command"
>  in the updated commit log message, in case you forgot to apply it
>  yourself.
>
>  I just didn't want to see the time you and others spent on submitting
>  and reviewing wasted due to lack of resubmission of a revised patch.

Very thoughtful.  I appreciate your occasional "playing a capable project
secretary", and I wish I see more like you.

Indeed I've been swamped, and I tend to leave the final wrapping up to the
original submitter and then forget.

Thanks.

^ permalink raw reply

* For review: git add --ignore-unmatch
From: Luke-Jr @ 2009-08-12 22:26 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: Text/Plain, Size: 1 bytes --]



[-- Attachment #2: 0001-port-ignore-unmatch-from-git-rm-to-git-add.patch --]
[-- Type: text/x-patch, Size: 2009 bytes --]

From 54768360aa7b1882dd2b76211661abb6014cbf23 Mon Sep 17 00:00:00 2001
From: Luke Dashjr <luke-jr+git@utopios.org>
Date: Wed, 12 Aug 2009 16:26:31 -0500
Subject: [PATCH 1/3] port --ignore-unmatch from "git rm" to "git add"

---
 builtin-add.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/builtin-add.c b/builtin-add.c
index 581a2a1..0597fb9 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -19,6 +19,7 @@ static const char * const builtin_add_usage[] = {
 };
 static int patch_interactive, add_interactive, edit_interactive;
 static int take_worktree_changes;
+static int ignore_unmatch = 0;
 
 static void fill_pathspec_matches(const char **pathspec, char *seen, int specs)
 {
@@ -63,7 +64,7 @@ static void prune_directory(struct dir_struct *dir, const char **pathspec, int p
 	fill_pathspec_matches(pathspec, seen, specs);
 
 	for (i = 0; i < specs; i++) {
-		if (!seen[i] && pathspec[i][0] && !file_exists(pathspec[i]))
+		if (!seen[i] && pathspec[i][0] && !file_exists(pathspec[i]) && !ignore_unmatch)
 			die("pathspec '%s' did not match any files",
 					pathspec[i]);
 	}
@@ -108,7 +109,7 @@ static void refresh(int verbose, const char **pathspec)
 	refresh_index(&the_index, verbose ? REFRESH_SAY_CHANGED : REFRESH_QUIET,
 		      pathspec, seen);
 	for (i = 0; i < specs; i++) {
-		if (!seen[i])
+		if (!seen[i] && !ignore_unmatch)
 			die("pathspec '%s' did not match any files", pathspec[i]);
 	}
         free(seen);
@@ -226,6 +227,8 @@ static struct option builtin_add_options[] = {
 	OPT_BOOLEAN('A', "all", &addremove, "add all, noticing removal of tracked files"),
 	OPT_BOOLEAN( 0 , "refresh", &refresh_only, "don't add, only refresh the index"),
 	OPT_BOOLEAN( 0 , "ignore-errors", &ignore_add_errors, "just skip files which cannot be added because of errors"),
+	OPT_BOOLEAN( 0 , "ignore-unmatch", &ignore_unmatch,
+				"exit with a zero status even if nothing matched"),
 	OPT_END(),
 };
 
-- 
1.6.3.3


[-- Attachment #3: 0002-fix-git-add-ignore-errors-to-ignore-pathspec-errors.patch --]
[-- Type: text/x-patch, Size: 761 bytes --]

From c6cd06db8ab3b198eafffd5b0e94d2f338f10072 Mon Sep 17 00:00:00 2001
From: Luke Dashjr <luke-jr+git@utopios.org>
Date: Wed, 12 Aug 2009 16:31:37 -0500
Subject: [PATCH 2/3] fix "git add --ignore-errors" to ignore pathspec errors

---
 builtin-add.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/builtin-add.c b/builtin-add.c
index 0597fb9..e3132c8 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -280,6 +280,8 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 		add_interactive = 1;
 	if (add_interactive)
 		exit(interactive_add(argc - 1, argv + 1, prefix));
+	if (ignore_add_errors)
+		ignore_unmatch = 1;
 
 	if (edit_interactive)
 		return(edit_patch(argc, argv, prefix));
-- 
1.6.3.3


[-- Attachment #4: 0003-Document-ignore-unmatch-in-git-add.txt.patch --]
[-- Type: text/x-patch, Size: 1217 bytes --]

From 410a93cb61669304a0b1d10b8013d1635432e8a0 Mon Sep 17 00:00:00 2001
From: Luke Dashjr <luke-jr+git@utopios.org>
Date: Wed, 12 Aug 2009 17:23:44 -0500
Subject: [PATCH 3/3] Document --ignore-unmatch in git-add.txt

---
 Documentation/git-add.txt |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
index ab1943c..6b93b4e 100644
--- a/Documentation/git-add.txt
+++ b/Documentation/git-add.txt
@@ -10,7 +10,8 @@ SYNOPSIS
 [verse]
 'git add' [-n] [-v] [--force | -f] [--interactive | -i] [--patch | -p]
 	  [--edit | -e] [--all | [--update | -u]] [--intent-to-add | -N]
-	  [--refresh] [--ignore-errors] [--] <filepattern>...
+	  [--refresh] [--ignore-errors] [--ignore-unmatch] [--]
+	  <filepattern>...
 
 DESCRIPTION
 -----------
@@ -119,6 +120,9 @@ apply.
 	them, do not abort the operation, but continue adding the
 	others. The command shall still exit with non-zero status.
 
+--ignore-unmatch::
+	Exit with a zero status even if no files matched.
+
 \--::
 	This option can be used to separate command-line options from
 	the list of files, (useful when filenames might be mistaken
-- 
1.6.3.3


^ permalink raw reply related

* Re: [RFC/PATCH 2/6] transport_get(): Don't SEGFAULT on missing url
From: Junio C Hamano @ 2009-08-12 22:24 UTC (permalink / raw)
  To: Johan Herland; +Cc: git, barkalow, benji, Johannes.Schindelin
In-Reply-To: <1249985426-13726-3-git-send-email-johan@herland.net>

Johan Herland <johan@herland.net> writes:

> Signed-off-by: Johan Herland <johan@herland.net>

How does url end up to be NULL?  At the beginning of transport_get(), you
do this:

	ret->remote = remote;
	if (!url && remote && remote->url)
		url = remote->url[0];
	ret->url = url;
	if (remote && remote->foreign_vcs) {
		transport_helper_init(ret);
		return ret;
	}

and the case where remote.$name.vcs is defined, we do not need
remote.$name.url.

When (!url && remote && remote->url), is remote->url[0] allowed to be
NULL?  I am guessing it would be a bug in whoever prepared the remote, and
if that is indeed the case, the patch shifts the symptoms without fixing
the cause.

When (remote && remote->foreign_vcs) does not hold, iow, if no remote is
defined or the remote is defined but lacks remote.$name.url, you will go
to the last else clause in the function that sets up a git_transport_data
for the native transport, but it has ret->url == NULL.  

Whom does that transport talk with?  Is such a transport of any use, or
does it cause a segfault downstream in the call chain?

In other words, I am wondering if this patch should just diagnose the case
as an error, instead of pretending all is well.

^ permalink raw reply

* Re: [PATCH 00/13] more changes to port rebase -i to C using sequencer code
From: Junio C Hamano @ 2009-08-12 21:49 UTC (permalink / raw)
  To: Christian Couder
  Cc: git, Johannes Schindelin, Stephan Beyer, Daniel Barkalow,
	Jakub Narebski
In-Reply-To: <20090812051116.18155.70541.chriscool@tuxfamily.org>

Christian Couder <chriscool@tuxfamily.org> writes:

> These is just the current state of my work.
> Some patches have already been sent but are not yet in pu.

It seems that some later patches in the series are "oops, the earlier one
made mistakes and this patch fixes them".  Could you fix them where they
were introduced?

^ permalink raw reply

* Re: [ANNOUNCE] Scumd
From: Michael Gaffney @ 2009-08-12 20:56 UTC (permalink / raw)
  To: git
In-Reply-To: <m3ws58ok1r.fsf@localhost.localdomain>

Done, thanks.

Jakub Narebski wrote:
> Michael Gaffney <mr.gaffo@gmail.com> writes:
>
>   
>>     This is an initial announcement of SCuMD, a pure java git sshd
>> daemon. The source is at git://github.com/gaffo/scumd. The impetus
>> behind SCuMD is to provide a highly configurable git daemon which can
>> authenticate and authorize off of flat files, databases, LDAP, web
>> services, or any other resource you can think of. SCuMD's other goal
>> is to remove the need to serve off of normal sshd which some find to
>> be a security risk on the open Internet. Currently SCuMD supports LDAP
>> as the authentication module but coding other modules is quite simple.
>>
>>     I would welcome any feedback including a better name. SCuMD stands
>> for SCM Daemon.
>>     
>
> Could you add information about this tool to Git Wiki:
> http://git.or.cz/gitwiki/InterfacesFrontendsAndTools
> perhaps below entry for gitosis?
>
> TIA
>   

^ permalink raw reply

* Re: [ANNOUNCE] Scumd
From: Alex Riesen @ 2009-08-12 21:10 UTC (permalink / raw)
  To: Michael Gaffney; +Cc: git
In-Reply-To: <4A8309D9.8070008@gmail.com>

On Wed, Aug 12, 2009 at 20:28, Michael Gaffney<mr.gaffo@gmail.com> wrote:
> ... SCuMD's other goal is to remove the need to serve
> off of normal sshd which some find to be a security risk on the open
> Internet. ...

I just wonder: how is your creation less of security risk than sshd?

^ permalink raw reply

* Re: situation codes (e.g. #16) in unpack-trees.c
From: Jeff King @ 2009-08-12 21:07 UTC (permalink / raw)
  To: Jeff Enderwick; +Cc: git
In-Reply-To: <bb6059c00908121405t4f34c50eo532b928fa6d6f89c@mail.gmail.com>

On Wed, Aug 12, 2009 at 02:05:06PM -0700, Jeff Enderwick wrote:

> Newbie here. I'm trying to grok git's merge algorithms. Where are
> those '#' codes written up (e.g. #16, #5ALT, etc)?
> Is there a write-up anywhere on the merge logic?

Try Documentation/technical/trivial-merge.txt.

-Peff

^ permalink raw reply

* situation codes (e.g. #16) in unpack-trees.c
From: Jeff Enderwick @ 2009-08-12 21:05 UTC (permalink / raw)
  To: git

Newbie here. I'm trying to grok git's merge algorithms. Where are
those '#' codes written up (e.g. #16, #5ALT, etc)?
Is there a write-up anywhere on the merge logic?

TIA,
Jeff

^ permalink raw reply

* [JGIT PATCH v2] Rename RevTag.getName() to RevTag.getTagName()
From: Shawn O. Pearce @ 2009-08-12 20:51 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: git
In-Reply-To: <200908122237.37148.robin.rosenberg.lists@dewire.com>

The method getName() conflicts semantically with the method name()
we have inherited from our base class, ObjectId.  It is a rather
unfortunate turn of events that for performance reasons we wind up
subclassing what should be a property of this class, but since we
do that we need to pay attention to the methods declared on our
base class.

We want to use getName() to be a mirror of name() on AnyObjectId,
as it has a more JavaBeans style feel to the accessing of that
particular value.  So, rename getTagName() so it doesn't wind up
conflicting with the SHA-1 hex formatted string.

Noticed-by: Alex Blewitt <alex.blewitt@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 Robin Rosenberg <robin.rosenberg.lists@dewire.com> wrote:
 > You forgot the rename of the method here, and all uses of it.

 Quite right.  #@*!! Eclipse.  I thought I refactored that method,
 but I guess it didn't actually do the work, and I failed to read
 the diff closely enough to notice.  *sigh* That's what I get for
 trying to quickly bang out a "simple" change.

 .../org/spearce/jgit/revwalk/RevTagParseTest.java  |    8 ++++----
 .../src/org/spearce/jgit/revwalk/RevTag.java       |   10 +++++-----
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevTagParseTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevTagParseTest.java
index 66bc901..9f91154 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevTagParseTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/revwalk/RevTagParseTest.java
@@ -75,7 +75,7 @@ private void testOneType(final int typeCode) throws Exception {
 
 		c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
 		assertNull(c.getObject());
-		assertNull(c.getName());
+		assertNull(c.getTagName());
 
 		c.parseCanonical(rw, b.toString().getBytes("UTF-8"));
 		assertNotNull(c.getObject());
@@ -117,15 +117,15 @@ public void testParseAllFields() throws Exception {
 
 		c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
 		assertNull(c.getObject());
-		assertNull(c.getName());
+		assertNull(c.getTagName());
 
 		c.parseCanonical(rw, body.toString().getBytes("UTF-8"));
 		assertNotNull(c.getObject());
 		assertEquals(treeId, c.getObject().getId());
 		assertSame(rw.lookupTree(treeId), c.getObject());
 
-		assertNotNull(c.getName());
-		assertEquals(name, c.getName());
+		assertNotNull(c.getTagName());
+		assertEquals(name, c.getTagName());
 		assertEquals("", c.getFullMessage());
 
 		final PersonIdent cTagger = c.getTaggerIdent();
diff --git a/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevTag.java b/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevTag.java
index 2fab266..204e9b1 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevTag.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevTag.java
@@ -56,7 +56,7 @@
 
 	private byte[] buffer;
 
-	private String name;
+	private String tagName;
 
 	/**
 	 * Create a new tag reference.
@@ -96,7 +96,7 @@ void parseCanonical(final RevWalk walk, final byte[] rawTag)
 
 		int p = pos.value += 4; // "tag "
 		final int nameEnd = RawParseUtils.nextLF(rawTag, p) - 1;
-		name = RawParseUtils.decode(Constants.CHARSET, rawTag, p, nameEnd);
+		tagName = RawParseUtils.decode(Constants.CHARSET, rawTag, p, nameEnd);
 
 		if (walk.isRetainBody())
 			buffer = rawTag;
@@ -186,7 +186,7 @@ public final String getShortMessage() {
 	 * @return parsed tag.
 	 */
 	public Tag asTag(final RevWalk walk) {
-		return new Tag(walk.db, this, name, buffer);
+		return new Tag(walk.db, this, tagName, buffer);
 	}
 
 	/**
@@ -203,8 +203,8 @@ public final RevObject getObject() {
 	 * 
 	 * @return name of the tag, according to the tag header.
 	 */
-	public final String getName() {
-		return name;
+	public final String getTagName() {
+		return tagName;
 	}
 
 	final void disposeBody() {
-- 
1.6.4.225.gb589e

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox