Git development
 help / color / mirror / Atom feed
* [PATCH 1/4] diff.c: shuffling code around
From: Junio C Hamano @ 2009-09-15  6:15 UTC (permalink / raw)
  To: git; +Cc: Nanako Shiraishi
In-Reply-To: <1252995306-32329-1-git-send-email-gitster@pobox.com>

Move function, type, and structure definitions for fill_mmfile(),
count_trailing_blank(), check_blank_at_eof(), emit_line(),
new_blank_line_at_eof(), emit_add_line(), sane_truncate_fn, and
emit_callback up in the file, so that they can be refactored into helper
functions and reused by codepath for emitting rewrite patches.

This only moves the lines around to make the next two patches easier to
read.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---

 * This obviously comes on top of the earlier fix to the "blank lines at
   eof" breakage.

 diff.c |  250 ++++++++++++++++++++++++++++++++--------------------------------
 1 files changed, 125 insertions(+), 125 deletions(-)

diff --git a/diff.c b/diff.c
index 63a3bfc..7548966 100644
--- a/diff.c
+++ b/diff.c
@@ -241,6 +241,23 @@ static struct diff_tempfile {
 	char tmp_path[PATH_MAX];
 } diff_temp[2];
 
+typedef unsigned long (*sane_truncate_fn)(char *line, unsigned long len);
+
+struct emit_callback {
+	struct xdiff_emit_state xm;
+	int color_diff;
+	unsigned ws_rule;
+	int blank_at_eof_in_preimage;
+	int blank_at_eof_in_postimage;
+	int lno_in_preimage;
+	int lno_in_postimage;
+	sane_truncate_fn truncate;
+	const char **label_path;
+	struct diff_words_data *diff_words;
+	int *found_changesp;
+	FILE *file;
+};
+
 static int count_lines(const char *data, int size)
 {
 	int count, ch, completely_empty = 1, nl_just_seen = 0;
@@ -301,6 +318,114 @@ static void copy_file_with_prefix(FILE *file,
 		fprintf(file, "%s\n\\ No newline at end of file\n", reset);
 }
 
+static int fill_mmfile(mmfile_t *mf, struct diff_filespec *one)
+{
+	if (!DIFF_FILE_VALID(one)) {
+		mf->ptr = (char *)""; /* does not matter */
+		mf->size = 0;
+		return 0;
+	}
+	else if (diff_populate_filespec(one, 0))
+		return -1;
+	mf->ptr = one->data;
+	mf->size = one->size;
+	return 0;
+}
+
+static int count_trailing_blank(mmfile_t *mf, unsigned ws_rule)
+{
+	char *ptr = mf->ptr;
+	long size = mf->size;
+	int cnt = 0;
+
+	if (!size)
+		return cnt;
+	ptr += size - 1; /* pointing at the very end */
+	if (*ptr != '\n')
+		; /* incomplete line */
+	else
+		ptr--; /* skip the last LF */
+	while (mf->ptr < ptr) {
+		char *prev_eol;
+		for (prev_eol = ptr; mf->ptr <= prev_eol; prev_eol--)
+			if (*prev_eol == '\n')
+				break;
+		if (!ws_blank_line(prev_eol + 1, ptr - prev_eol, ws_rule))
+			break;
+		cnt++;
+		ptr = prev_eol - 1;
+	}
+	return cnt;
+}
+
+static void check_blank_at_eof(mmfile_t *mf1, mmfile_t *mf2,
+			       struct emit_callback *ecbdata)
+{
+	int l1, l2, at;
+	unsigned ws_rule = ecbdata->ws_rule;
+	l1 = count_trailing_blank(mf1, ws_rule);
+	l2 = count_trailing_blank(mf2, ws_rule);
+	if (l2 <= l1) {
+		ecbdata->blank_at_eof_in_preimage = 0;
+		ecbdata->blank_at_eof_in_postimage = 0;
+		return;
+	}
+	at = count_lines(mf1->ptr, mf1->size);
+	ecbdata->blank_at_eof_in_preimage = (at - l1) + 1;
+
+	at = count_lines(mf2->ptr, mf2->size);
+	ecbdata->blank_at_eof_in_postimage = (at - l2) + 1;
+}
+
+static void emit_line(FILE *file, const char *set, const char *reset, const char *line, int len)
+{
+	int has_trailing_newline, has_trailing_carriage_return;
+
+	has_trailing_newline = (len > 0 && line[len-1] == '\n');
+	if (has_trailing_newline)
+		len--;
+	has_trailing_carriage_return = (len > 0 && line[len-1] == '\r');
+	if (has_trailing_carriage_return)
+		len--;
+
+	fputs(set, file);
+	fwrite(line, len, 1, file);
+	fputs(reset, file);
+	if (has_trailing_carriage_return)
+		fputc('\r', file);
+	if (has_trailing_newline)
+		fputc('\n', file);
+}
+
+static int new_blank_line_at_eof(struct emit_callback *ecbdata, const char *line, int len)
+{
+	if (!((ecbdata->ws_rule & WS_BLANK_AT_EOF) &&
+	      ecbdata->blank_at_eof_in_preimage &&
+	      ecbdata->blank_at_eof_in_postimage &&
+	      ecbdata->blank_at_eof_in_preimage <= ecbdata->lno_in_preimage &&
+	      ecbdata->blank_at_eof_in_postimage <= ecbdata->lno_in_postimage))
+		return 0;
+	return ws_blank_line(line + 1, len - 1, ecbdata->ws_rule);
+}
+
+static void emit_add_line(const char *reset, struct emit_callback *ecbdata, const char *line, int len)
+{
+	const char *ws = diff_get_color(ecbdata->color_diff, DIFF_WHITESPACE);
+	const char *set = diff_get_color(ecbdata->color_diff, DIFF_FILE_NEW);
+
+	if (!*ws)
+		emit_line(ecbdata->file, set, reset, line, len);
+	else if (new_blank_line_at_eof(ecbdata, line, len))
+		/* Blank line at EOF - paint '+' as well */
+		emit_line(ecbdata->file, ws, reset, line, len);
+	else {
+		/* Emit just the prefix, then the rest. */
+		emit_line(ecbdata->file, set, reset, line, 1);
+		ws_check_emit(line + 1, len - 1, ecbdata->ws_rule,
+			      ecbdata->file, set, reset, ws);
+	}
+}
+
 static void emit_rewrite_diff(const char *name_a,
 			      const char *name_b,
 			      struct diff_filespec *one,
@@ -345,20 +470,6 @@ static void emit_rewrite_diff(const char *name_a,
 		copy_file_with_prefix(o->file, '+', two->data, two->size, new, reset);
 }
 
-static int fill_mmfile(mmfile_t *mf, struct diff_filespec *one)
-{
-	if (!DIFF_FILE_VALID(one)) {
-		mf->ptr = (char *)""; /* does not matter */
-		mf->size = 0;
-		return 0;
-	}
-	else if (diff_populate_filespec(one, 0))
-		return -1;
-	mf->ptr = one->data;
-	mf->size = one->size;
-	return 0;
-}
-
 struct diff_words_buffer {
 	mmfile_t text;
 	long alloc;
@@ -485,23 +596,6 @@ static void diff_words_show(struct diff_words_data *diff_words)
 	}
 }
 
-typedef unsigned long (*sane_truncate_fn)(char *line, unsigned long len);
-
-struct emit_callback {
-	struct xdiff_emit_state xm;
-	int color_diff;
-	unsigned ws_rule;
-	int blank_at_eof_in_preimage;
-	int blank_at_eof_in_postimage;
-	int lno_in_preimage;
-	int lno_in_postimage;
-	sane_truncate_fn truncate;
-	const char **label_path;
-	struct diff_words_data *diff_words;
-	int *found_changesp;
-	FILE *file;
-};
-
 static void free_diff_words_data(struct emit_callback *ecbdata)
 {
 	if (ecbdata->diff_words) {
@@ -524,55 +618,6 @@ const char *diff_get_color(int diff_use_color, enum color_diff ix)
 	return "";
 }
 
-static void emit_line(FILE *file, const char *set, const char *reset, const char *line, int len)
-{
-	int has_trailing_newline, has_trailing_carriage_return;
-
-	has_trailing_newline = (len > 0 && line[len-1] == '\n');
-	if (has_trailing_newline)
-		len--;
-	has_trailing_carriage_return = (len > 0 && line[len-1] == '\r');
-	if (has_trailing_carriage_return)
-		len--;
-
-	fputs(set, file);
-	fwrite(line, len, 1, file);
-	fputs(reset, file);
-	if (has_trailing_carriage_return)
-		fputc('\r', file);
-	if (has_trailing_newline)
-		fputc('\n', file);
-}
-
-static int new_blank_line_at_eof(struct emit_callback *ecbdata, const char *line, int len)
-{
-	if (!((ecbdata->ws_rule & WS_BLANK_AT_EOF) &&
-	      ecbdata->blank_at_eof_in_preimage &&
-	      ecbdata->blank_at_eof_in_postimage &&
-	      ecbdata->blank_at_eof_in_preimage <= ecbdata->lno_in_preimage &&
-	      ecbdata->blank_at_eof_in_postimage <= ecbdata->lno_in_postimage))
-		return 0;
-	return ws_blank_line(line + 1, len - 1, ecbdata->ws_rule);
-}
-
-static void emit_add_line(const char *reset, struct emit_callback *ecbdata, const char *line, int len)
-{
-	const char *ws = diff_get_color(ecbdata->color_diff, DIFF_WHITESPACE);
-	const char *set = diff_get_color(ecbdata->color_diff, DIFF_FILE_NEW);
-
-	if (!*ws)
-		emit_line(ecbdata->file, set, reset, line, len);
-	else if (new_blank_line_at_eof(ecbdata, line, len))
-		/* Blank line at EOF - paint '+' as well */
-		emit_line(ecbdata->file, ws, reset, line, len);
-	else {
-		/* Emit just the prefix, then the rest. */
-		emit_line(ecbdata->file, set, reset, line, 1);
-		ws_check_emit(line + 1, len - 1, ecbdata->ws_rule,
-			      ecbdata->file, set, reset, ws);
-	}
-}
-
 static unsigned long sane_truncate_line(struct emit_callback *ecb, char *line, unsigned long len)
 {
 	const char *cp;
@@ -1464,51 +1509,6 @@ static const struct funcname_pattern_entry *diff_funcname_pattern(struct diff_fi
 	return NULL;
 }
 
-static int count_trailing_blank(mmfile_t *mf, unsigned ws_rule)
-{
-	char *ptr = mf->ptr;
-	long size = mf->size;
-	int cnt = 0;
-
-	if (!size)
-		return cnt;
-	ptr += size - 1; /* pointing at the very end */
-	if (*ptr != '\n')
-		; /* incomplete line */
-	else
-		ptr--; /* skip the last LF */
-	while (mf->ptr < ptr) {
-		char *prev_eol;
-		for (prev_eol = ptr; mf->ptr <= prev_eol; prev_eol--)
-			if (*prev_eol == '\n')
-				break;
-		if (!ws_blank_line(prev_eol + 1, ptr - prev_eol, ws_rule))
-			break;
-		cnt++;
-		ptr = prev_eol - 1;
-	}
-	return cnt;
-}
-
-static void check_blank_at_eof(mmfile_t *mf1, mmfile_t *mf2,
-			       struct emit_callback *ecbdata)
-{
-	int l1, l2, at;
-	unsigned ws_rule = ecbdata->ws_rule;
-	l1 = count_trailing_blank(mf1, ws_rule);
-	l2 = count_trailing_blank(mf2, ws_rule);
-	if (l2 <= l1) {
-		ecbdata->blank_at_eof_in_preimage = 0;
-		ecbdata->blank_at_eof_in_postimage = 0;
-		return;
-	}
-	at = count_lines(mf1->ptr, mf1->size);
-	ecbdata->blank_at_eof_in_preimage = (at - l1) + 1;
-
-	at = count_lines(mf2->ptr, mf2->size);
-	ecbdata->blank_at_eof_in_postimage = (at - l2) + 1;
-}
-
 static void builtin_diff(const char *name_a,
 			 const char *name_b,
 			 struct diff_filespec *one,
-- 
1.6.5.rc1.54.g4aad

^ permalink raw reply related

* [PATCH 2/4] diff.c: split emit_line() from the first char and the rest of the line
From: Junio C Hamano @ 2009-09-15  6:15 UTC (permalink / raw)
  To: git; +Cc: Nanako Shiraishi
In-Reply-To: <1252995306-32329-1-git-send-email-gitster@pobox.com>

A new helper function emit_line_0() takes the first line of diff output
(typically "-", " ", or "+") separately from the remainder of the line.
No other functional changes.

This change will make it easier to reuse the logic when emitting the
rewrite diff, as we do not want to copy a line only to add "+"/"-"/" "
immediately before its first character when we produce rewrite diff
output.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 diff.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/diff.c b/diff.c
index 7548966..b5c2574 100644
--- a/diff.c
+++ b/diff.c
@@ -377,7 +377,8 @@ static void check_blank_at_eof(mmfile_t *mf1, mmfile_t *mf2,
 	ecbdata->blank_at_eof_in_postimage = (at - l2) + 1;
 }
 
-static void emit_line(FILE *file, const char *set, const char *reset, const char *line, int len)
+static void emit_line_0(FILE *file, const char *set, const char *reset,
+			int first, const char *line, int len)
 {
 	int has_trailing_newline, has_trailing_carriage_return;
 
@@ -389,6 +390,7 @@ static void emit_line(FILE *file, const char *set, const char *reset, const char
 		len--;
 
 	fputs(set, file);
+	fputc(first, file);
 	fwrite(line, len, 1, file);
 	fputs(reset, file);
 	if (has_trailing_carriage_return)
@@ -397,6 +399,12 @@ static void emit_line(FILE *file, const char *set, const char *reset, const char
 		fputc('\n', file);
 }
 
+static void emit_line(FILE *file, const char *set, const char *reset,
+		      const char *line, int len)
+{
+	emit_line_0(file, set, reset, line[0], line+1, len-1);
+}
+
 static int new_blank_line_at_eof(struct emit_callback *ecbdata, const char *line, int len)
 {
 	if (!((ecbdata->ws_rule & WS_BLANK_AT_EOF) &&
-- 
1.6.5.rc1.54.g4aad

^ permalink raw reply related

* [PATCH 4/4] diff -B: colour whitespace errors
From: Junio C Hamano @ 2009-09-15  6:15 UTC (permalink / raw)
  To: git; +Cc: Nanako Shiraishi
In-Reply-To: <1252995306-32329-1-git-send-email-gitster@pobox.com>

We used to send the old and new contents more or less straight out to the
output with only the original "old is red, new is green" colouring.  Now
all the necessary support routines have been prepared, call them with a
line of data at a time from the output code and have them check and color
whitespace errors in exactly the same way as they are called from the low
level diff callback routines.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 diff.c |   75 +++++++++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 49 insertions(+), 26 deletions(-)

diff --git a/diff.c b/diff.c
index baf46ab..b6d40d7 100644
--- a/diff.c
+++ b/diff.c
@@ -296,28 +296,6 @@ static void print_line_count(FILE *file, int count)
 	}
 }
 
-static void copy_file_with_prefix(FILE *file,
-				  int prefix, const char *data, int size,
-				  const char *set, const char *reset)
-{
-	int ch, nl_just_seen = 1;
-	while (0 < size--) {
-		ch = *data++;
-		if (nl_just_seen) {
-			fputs(set, file);
-			putc(prefix, file);
-		}
-		if (ch == '\n') {
-			nl_just_seen = 1;
-			fputs(reset, file);
-		} else
-			nl_just_seen = 0;
-		putc(ch, file);
-	}
-	if (!nl_just_seen)
-		fprintf(file, "%s\n\\ No newline at end of file\n", reset);
-}
-
 static int fill_mmfile(mmfile_t *mf, struct diff_filespec *one)
 {
 	if (!DIFF_FILE_VALID(one)) {
@@ -436,6 +414,38 @@ static void emit_add_line(const char *reset,
 	}
 }
 
+static void emit_rewrite_lines(struct emit_callback *ecb,
+			       int prefix, const char *data, int size)
+{
+	const char *endp = NULL;
+	static const char *nneof = " No newline at end of file\n";
+	const char *old = diff_get_color(ecb->color_diff, DIFF_FILE_OLD);
+	const char *reset = diff_get_color(ecb->color_diff, DIFF_RESET);
+
+	while (0 < size) {
+		int len;
+
+		endp = memchr(data, '\n', size);
+		len = endp ? (endp - data + 1) : size;
+		if (prefix != '+') {
+			ecb->lno_in_preimage++;
+			emit_line_0(ecb->file, old, reset, '-',
+				    data, len);
+		} else {
+			ecb->lno_in_postimage++;
+			emit_add_line(reset, ecb, data, len);
+		}
+		size -= len;
+		data += len;
+	}
+	if (!endp) {
+		const char *plain = diff_get_color(ecb->color_diff,
+						   DIFF_PLAIN);
+		emit_line_0(ecb->file, plain, reset, '\\',
+			    nneof, strlen(nneof));
+	}
+}
+
 static void emit_rewrite_diff(const char *name_a,
 			      const char *name_b,
 			      struct diff_filespec *one,
@@ -447,10 +457,23 @@ static void emit_rewrite_diff(const char *name_a,
 	const char *name_a_tab, *name_b_tab;
 	const char *metainfo = diff_get_color(color_diff, DIFF_METAINFO);
 	const char *fraginfo = diff_get_color(color_diff, DIFF_FRAGINFO);
-	const char *old = diff_get_color(color_diff, DIFF_FILE_OLD);
-	const char *new = diff_get_color(color_diff, DIFF_FILE_NEW);
 	const char *reset = diff_get_color(color_diff, DIFF_RESET);
 	static struct strbuf a_name = STRBUF_INIT, b_name = STRBUF_INIT;
+	struct emit_callback ecbdata;
+
+	memset(&ecbdata, 0, sizeof(ecbdata));
+	ecbdata.color_diff = color_diff;
+	ecbdata.found_changesp = &o->found_changes;
+	ecbdata.ws_rule = whitespace_rule(name_b ? name_b : name_a);
+	ecbdata.file = o->file;
+	if (ecbdata.ws_rule & WS_BLANK_AT_EOF) {
+		mmfile_t mf1, mf2;
+		fill_mmfile(&mf1, one);
+		fill_mmfile(&mf2, two);
+		check_blank_at_eof(&mf1, &mf2, &ecbdata);
+	}
+	ecbdata.lno_in_preimage = 1;
+	ecbdata.lno_in_postimage = 1;
 
 	name_a += (*name_a == '/');
 	name_b += (*name_b == '/');
@@ -475,9 +498,9 @@ static void emit_rewrite_diff(const char *name_a,
 	print_line_count(o->file, lc_b);
 	fprintf(o->file, " @@%s\n", reset);
 	if (lc_a)
-		copy_file_with_prefix(o->file, '-', one->data, one->size, old, reset);
+		emit_rewrite_lines(&ecbdata, '-', one->data, one->size);
 	if (lc_b)
-		copy_file_with_prefix(o->file, '+', two->data, two->size, new, reset);
+		emit_rewrite_lines(&ecbdata, '+', two->data, two->size);
 }
 
 struct diff_words_buffer {
-- 
1.6.5.rc1.54.g4aad

^ permalink raw reply related

* [PATCH 3/4] diff.c: emit_add_line() takes only the rest of the line
From: Junio C Hamano @ 2009-09-15  6:15 UTC (permalink / raw)
  To: git; +Cc: Nanako Shiraishi
In-Reply-To: <1252995306-32329-1-git-send-email-gitster@pobox.com>

As the first character on the line that is fed to this function is always
"+", it is pointless to send that along with the rest of the line.

This change will make it easier to reuse the logic when emitting the
rewrite diff, as we do not want to copy a line only to add "+"/"-"/" "
immediately before its first character when we produce rewrite diff
output.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 diff.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/diff.c b/diff.c
index b5c2574..baf46ab 100644
--- a/diff.c
+++ b/diff.c
@@ -416,20 +416,22 @@ static int new_blank_line_at_eof(struct emit_callback *ecbdata, const char *line
 	return ws_blank_line(line + 1, len - 1, ecbdata->ws_rule);
 }
 
-static void emit_add_line(const char *reset, struct emit_callback *ecbdata, const char *line, int len)
+static void emit_add_line(const char *reset,
+			  struct emit_callback *ecbdata,
+			  const char *line, int len)
 {
 	const char *ws = diff_get_color(ecbdata->color_diff, DIFF_WHITESPACE);
 	const char *set = diff_get_color(ecbdata->color_diff, DIFF_FILE_NEW);
 
 	if (!*ws)
-		emit_line(ecbdata->file, set, reset, line, len);
+		emit_line_0(ecbdata->file, set, reset, '+', line, len);
 	else if (new_blank_line_at_eof(ecbdata, line, len))
 		/* Blank line at EOF - paint '+' as well */
-		emit_line(ecbdata->file, ws, reset, line, len);
+		emit_line_0(ecbdata->file, ws, reset, '+', line, len);
 	else {
 		/* Emit just the prefix, then the rest. */
-		emit_line(ecbdata->file, set, reset, line, 1);
-		ws_check_emit(line + 1, len - 1, ecbdata->ws_rule,
+		emit_line_0(ecbdata->file, set, reset, '+', "", 0);
+		ws_check_emit(line, len, ecbdata->ws_rule,
 			      ecbdata->file, set, reset, ws);
 	}
 }
@@ -726,7 +728,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
 		emit_line(ecbdata->file, color, reset, line, len);
 	} else {
 		ecbdata->lno_in_postimage++;
-		emit_add_line(reset, ecbdata, line, len);
+		emit_add_line(reset, ecbdata, line + 1, len - 1);
 	}
 }
 
-- 
1.6.5.rc1.54.g4aad

^ permalink raw reply related

* Re: [PATCH] Improve --patch option documentation in git-add (updated patch)
From: Nanako Shiraishi @ 2009-09-15  6:52 UTC (permalink / raw)
  To: Jari Aalto; +Cc: Sean Estabrooks, Mikael Magnusson, git
In-Reply-To: <87fxaolqhd.fsf_-_@jondo.cante.net>

Quoting Jari Aalto <jari.aalto@cante.net>

> Sean Estabrooks <seanlkml@sympatico.ca> writes:
>> ... To me though, it seems more difficult to parse this description
>> than the one offered by Junio in an earlier thread ...perhaps you'd
>> consider something closer to yours, such as:
>>
>> 	Interactively review the differences between the index and the
>> 	work tree and choose which hunks to add into the index.
>>
>> 	This effectively runs ``add --interactive``, but bypasses the
>> 	initial command menu and jumps directly to the `patch` subcommand.
>> 	See ``Interactive mode'' for details.
>
>
> Updated, thanks,
> Jari
>
>
> From be5eebc53c2e3dcf67edfb371d8aa8263e1a8d69 Mon Sep 17 00:00:00 2001
> From: Jari Aalto <jari.aalto@cante.net>
> Date: Tue, 15 Sep 2009 08:33:51 +0300
> Subject: [PATCH] Improve --patch option documentation in git-add
>
> Signed-off-by: Jari Aalto <jari.aalto@cante.net>
> ---
>  Documentation/git-add.txt |    9 ++++++---
>  1 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
> index e67b7e8..c57895a 100644
> --- a/Documentation/git-add.txt
> +++ b/Documentation/git-add.txt
> @@ -72,9 +72,12 @@ OPTIONS
>  
>  -p::
>  --patch::
> -	Similar to Interactive mode but the initial command loop is
> -	bypassed and the 'patch' subcommand is invoked using each of
> -	the specified filepatterns before exiting.
> +	Interactively review the differences between the index and the
> +	work tree and choose which hunks to add into the index.
> +
> +	This effectively runs ``add --interactive``, but bypasses the
> +	initial command menu and jumps directly to the `patch` subcommand.
> +	See ``Interactive mode'' for details.
>  
>  -e, \--edit::
>  	Open the diff vs. the index in an editor and let the user

Sorry, but this patch doesn't seem to apply anywhere. Have you fetched recently?

-- 
Nanako Shiraishi
http://ivory.ap.teacup.com/nanako3/

^ permalink raw reply

* Re: [PATCH 0/4] Colouring whitespace errors in diff -B output
From: Nanako Shiraishi @ 2009-09-15  6:52 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <1252995306-32329-1-git-send-email-gitster@pobox.com>

Quoting Junio C Hamano <gitster@pobox.com>

> Here is a 4-patch miniseries to teach "diff -B" output routines to detect
> and colour whitespace errors like we do for normal patches.
>
> The first three patches are only about moving code around without changing
> anything.
>
> The last one hooks "diff -B" logic to the per-line output routines in a
> way that mimicks how the normal patches are fed to them better, in order
> to take advantage of all the existing whitespace error detection and
> colouring logic.
>
> Junio C Hamano (4):
>       diff.c: shuffling code around
>       diff.c: split emit_line() from the first char and the rest of the line
>       diff.c: emit_add_line() takes only the rest of the line
>       diff -B: colour whitespace errors
>
>  diff.c |  327 +++++++++++++++++++++++++++++++++++-----------------------------
>  1 files changed, 180 insertions(+), 147 deletions(-)

Sorry, but I don't seem to be able to apply these patches anywhere.

-- 
Nanako Shiraishi
http://ivory.ap.teacup.com/nanako3/

^ permalink raw reply

* Re: [PATCH] Improve --patch option documentation in git-add (updated patch)
From: Jari Aalto @ 2009-09-15  8:17 UTC (permalink / raw)
  To: Nanako Shiraishi; +Cc: Sean Estabrooks, Mikael Magnusson, git
In-Reply-To: <20090915155208.6117@nanako3.lavabit.com>

Nanako Shiraishi <nanako3@lavabit.com> writes:

> Sorry, but this patch doesn't seem to apply anywhere. Have you fetched recently?

Junio merged the patch at 5f2b1e6

Jari

^ permalink raw reply

* [PATCH 1/4] bash: rename __git_find_subcommand() to __git_find_on_cmdline()
From: SZEDER Gábor @ 2009-09-15 10:21 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git, Junio C Hamano, SZEDER Gábor

__git_find_subcommand() was originally meant to check whether
subcommands are already present on the command line.  But the code is
general enough to be used for checking the presence of command line
options as well, and the next commit will use it for that purpose, so
let's give it a more general name.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
---
 contrib/completion/git-completion.bash |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index f47c519..c539385 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -619,8 +619,8 @@ __git_aliased_command ()
 	done
 }
 
-# __git_find_subcommand requires 1 argument
-__git_find_subcommand ()
+# __git_find_on_cmdline requires 1 argument
+__git_find_on_cmdline ()
 {
 	local word subcommand c=1
 
@@ -739,7 +739,7 @@ _git_bisect ()
 	__git_has_doubledash && return
 
 	local subcommands="start bad good skip reset visualize replay log run"
-	local subcommand="$(__git_find_subcommand "$subcommands")"
+	local subcommand="$(__git_find_on_cmdline "$subcommands")"
 	if [ -z "$subcommand" ]; then
 		__gitcomp "$subcommands"
 		return
@@ -1751,7 +1751,7 @@ _git_config ()
 _git_remote ()
 {
 	local subcommands="add rename rm show prune update set-head"
-	local subcommand="$(__git_find_subcommand "$subcommands")"
+	local subcommand="$(__git_find_on_cmdline "$subcommands")"
 	if [ -z "$subcommand" ]; then
 		__gitcomp "$subcommands"
 		return
@@ -1879,7 +1879,7 @@ _git_show_branch ()
 _git_stash ()
 {
 	local subcommands='save list show apply clear drop pop create branch'
-	local subcommand="$(__git_find_subcommand "$subcommands")"
+	local subcommand="$(__git_find_on_cmdline "$subcommands")"
 	if [ -z "$subcommand" ]; then
 		__gitcomp "$subcommands"
 	else
@@ -1910,7 +1910,7 @@ _git_submodule ()
 	__git_has_doubledash && return
 
 	local subcommands="add status init update summary foreach sync"
-	if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
+	if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
 		local cur="${COMP_WORDS[COMP_CWORD]}"
 		case "$cur" in
 		--*)
@@ -1932,7 +1932,7 @@ _git_svn ()
 		proplist show-ignore show-externals branch tag blame
 		migrate
 		"
-	local subcommand="$(__git_find_subcommand "$subcommands")"
+	local subcommand="$(__git_find_on_cmdline "$subcommands")"
 	if [ -z "$subcommand" ]; then
 		__gitcomp "$subcommands"
 	else
-- 
1.6.5.rc1.92.gee3c1

^ permalink raw reply related

* [PATCH 2/4] bash: update 'git stash' completion
From: SZEDER Gábor @ 2009-09-15 10:21 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git, Junio C Hamano, SZEDER Gábor
In-Reply-To: <e927e4d3bfe50d93e5e6d65c46821158332b37f9.1253009868.git.szeder@ira.uka.de>

This update adds 'git stash (apply|pop) --quiet' and all options known
to 'git stash save', and handles the DWIMery from 3c2eb80f (stash:
simplify defaulting to "save" and reject unknown options, 2009-08-18).
Care is taken to avoid offering subcommands in the DWIM case.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
---
 contrib/completion/git-completion.bash |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index c539385..2529cec 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1878,18 +1878,30 @@ _git_show_branch ()
 
 _git_stash ()
 {
+	local cur="${COMP_WORDS[COMP_CWORD]}"
+	local save_opts='--keep-index --no-keep-index --quiet --patch'
 	local subcommands='save list show apply clear drop pop create branch'
 	local subcommand="$(__git_find_on_cmdline "$subcommands")"
 	if [ -z "$subcommand" ]; then
-		__gitcomp "$subcommands"
+		case "$cur" in
+		--*)
+			__gitcomp "$save_opts"
+			;;
+		*)
+			if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
+				__gitcomp "$subcommands"
+			else
+				COMPREPLY=()
+			fi
+			;;
+		esac
 	else
-		local cur="${COMP_WORDS[COMP_CWORD]}"
 		case "$subcommand,$cur" in
 		save,--*)
-			__gitcomp "--keep-index"
+			__gitcomp "$save_opts"
 			;;
 		apply,--*|pop,--*)
-			__gitcomp "--index"
+			__gitcomp "--index --quiet"
 			;;
 		show,--*|drop,--*|branch,--*)
 			COMPREPLY=()
-- 
1.6.5.rc1.92.gee3c1

^ permalink raw reply related

* [PATCH 3/4] bash: teach 'git reset --patch'
From: SZEDER Gábor @ 2009-09-15 10:21 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git, Junio C Hamano, SZEDER Gábor
In-Reply-To: <e927e4d3bfe50d93e5e6d65c46821158332b37f9.1253009868.git.szeder@ira.uka.de>

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
---
 contrib/completion/git-completion.bash |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 2529cec..8c268a1 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1782,7 +1782,7 @@ _git_reset ()
 	local cur="${COMP_WORDS[COMP_CWORD]}"
 	case "$cur" in
 	--*)
-		__gitcomp "--merge --mixed --hard --soft"
+		__gitcomp "--merge --mixed --hard --soft --patch"
 		return
 		;;
 	esac
-- 
1.6.5.rc1.92.gee3c1

^ permalink raw reply related

* [PATCH 4/4] bash: teach 'git checkout' options
From: SZEDER Gábor @ 2009-09-15 10:21 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git, Junio C Hamano, SZEDER Gábor
In-Reply-To: <e927e4d3bfe50d93e5e6d65c46821158332b37f9.1253009868.git.szeder@ira.uka.de>

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
---
 contrib/completion/git-completion.bash |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 8c268a1..8e3cdbd 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -809,7 +809,18 @@ _git_checkout ()
 {
 	__git_has_doubledash && return
 
-	__gitcomp "$(__git_refs)"
+	local cur="${COMP_WORDS[COMP_CWORD]}"
+	case "$cur" in
+	--*)
+		__gitcomp "
+			--quiet --ours --theirs --track --no-track --merge
+			--conflict= --patch
+			"
+		;;
+	*)
+		__gitcomp "$(__git_refs)"
+		;;
+	esac
 }
 
 _git_cherry ()
-- 
1.6.5.rc1.92.gee3c1

^ permalink raw reply related

* Commited to wrong branch
From: Howard Miller @ 2009-09-15 10:31 UTC (permalink / raw)
  To: git

Hi,

I am resurrecting a discussion from a week or two back (been on
holiday).  As follows...

I had made some changes to some files and then done a commit. Only
then did I realise that I had the wrong branch checked out. To make
matters worse I then did a 'git reset HEAD^' which means that I can
now no longer switch branches. I am stuck. I had some advice (thanks!)
but it was not complete. I'd appreciate some more help.

I was advised to do a 'git reflog --branchname--' (I don't
know/understand what this command does) but it doesn't work. I just
get 'usage: git reflog (expire | ...)'

So basically I am no further forward. Just to reiterate I need to...

* remove the commit from my current branch (it tracks a remote so I
would prefer there to be no evidence to confuse other people after I
push)
* add the changes to the (other) branch they should have been added to.
* not loose or break anything.

Any (more) help appreciated.

^ permalink raw reply

* Re: [PATCH] Improve --patch option documentation in git-add (updated patch)
From: Nanako Shiraishi @ 2009-09-15 10:35 UTC (permalink / raw)
  To: Jari Aalto; +Cc: Sean Estabrooks, Mikael Magnusson, git
In-Reply-To: <87tyz4k4eg.fsf@jondo.cante.net>

Quoting Jari Aalto <jari.aalto@cante.net>

> Nanako Shiraishi <nanako3@lavabit.com> writes:
>
>> Sorry, but this patch doesn't seem to apply anywhere. Have you fetched recently?
>
> Junio merged the patch at 5f2b1e6

Oh, I see.

If so, could you rebase and resend?

It would also be nicer if you followed Documentation/SubmittingPatches when composing your message, writing any additional comments after the three dashes line.

Thank you.

-- 
Nanako Shiraishi
http://ivory.ap.teacup.com/nanako3/

^ permalink raw reply

* Re: Commited to wrong branch
From: Martin Langhoff @ 2009-09-15 10:55 UTC (permalink / raw)
  To: Howard Miller; +Cc: git
In-Reply-To: <26ae428a0909150331q391ed39ak622902d175b46d84@mail.gmail.com>

On Tue, Sep 15, 2009 at 12:31 PM, Howard Miller
<howard@e-learndesign.co.uk> wrote:
> I am resurrecting a discussion from a week or two back (been on
> holiday).  As follows...
>
> I had made some changes to some files and then done a commit. Only
> then did I realise that I had the wrong branch checked out. To make
> matters worse I then did a 'git reset HEAD^' which means that I can
> now no longer switch branches. I am stuck. I had some advice (thanks!)
> but it was not complete. I'd appreciate some more help.

Hi Howard,

just to make sure I understand your issue

  1 - you were on branch X, thinking your were on branch Y
  2 - edit, diff, commit, realised the mistake
  3 - git reset HEAD^

so if you now run `git status` and `git diff` it will show your
changes as if they were uncommitted and unstaged.

(Before you start with various attempts to recover below, a great
trick is to make an instant-backup in case things go wrong: cd .. / ;
cp -pr moodle.git moodle-backup.git ; cd moodle.git )

You can now try do do

  4 - git checkout Y

and if the changes are on files that don't change between X and Y,
then git will change the branches and keep your changes there. If the
files are different between X and Y, it won't work.

What I can recommend is to save your patch, as follows

  5 - git diff > tempchanges.patch
  6 - git reset --hard # this will discard your changes, careful
  7 - git checkout Y
  8 - patch -p1 < tempchanges.patch

The patch may not apply cleanly :-) -- note that patch is more
tolerant of iffy merges than git's internal implementation ("git
apply") -- so it will succeed more often... but the results need
review.

There is a more git-style approach that is to use git-stash -- it uses
git-apply and may not do what you want. The steps are

 5a - git stash # will save your changed files into a "stashed commit"
and clear out the changes from your working copy
 6a - git checkout Y
 7a - git stash apply

hth,



m
-- 
 martin.langhoff@gmail.com
 martin@laptop.org -- School Server Architect
 - ask interesting questions
 - don't get distracted with shiny stuff  - working code first
 - http://wiki.laptop.org/go/User:Martinlanghoff

^ permalink raw reply

* Re: Commited to wrong branch
From: Howard Miller @ 2009-09-15 11:05 UTC (permalink / raw)
  To: Martin Langhoff; +Cc: git
In-Reply-To: <46a038f90909150355h20b39c71w4af7e2be2920fdbb@mail.gmail.com>

Hi Martin,

I'm pretty shocked how difficult this is... still...

I'm finding git logs and reflogs pretty difficult to read and
interpret (head melting) - in particular telling what happened on what
branch - but looking at the reflog (which I assume is showing me the
actions on the current branch, but I'm not sure) I think I must have
made two commits on the wrong branch so the reset has only 'popped'
the top one. Other than that your interpretation is correct.

I cannot currently change branches - it only complains about one file.
I'm a bit worried about that - I would like to understand why this is
a problem but I don't.

So I am now a little hazy on how to deal with previous TWO commits.

Sorry for misery.... I've lost the plot a bit here :-)

Howard



2009/9/15 Martin Langhoff <martin.langhoff@gmail.com>:
> On Tue, Sep 15, 2009 at 12:31 PM, Howard Miller
> <howard@e-learndesign.co.uk> wrote:
>> I am resurrecting a discussion from a week or two back (been on
>> holiday).  As follows...
>>
>> I had made some changes to some files and then done a commit. Only
>> then did I realise that I had the wrong branch checked out. To make
>> matters worse I then did a 'git reset HEAD^' which means that I can
>> now no longer switch branches. I am stuck. I had some advice (thanks!)
>> but it was not complete. I'd appreciate some more help.
>
> Hi Howard,
>
> just to make sure I understand your issue
>
>  1 - you were on branch X, thinking your were on branch Y
>  2 - edit, diff, commit, realised the mistake
>  3 - git reset HEAD^
>
> so if you now run `git status` and `git diff` it will show your
> changes as if they were uncommitted and unstaged.
>
> (Before you start with various attempts to recover below, a great
> trick is to make an instant-backup in case things go wrong: cd .. / ;
> cp -pr moodle.git moodle-backup.git ; cd moodle.git )
>
> You can now try do do
>
>  4 - git checkout Y
>
> and if the changes are on files that don't change between X and Y,
> then git will change the branches and keep your changes there. If the
> files are different between X and Y, it won't work.
>
> What I can recommend is to save your patch, as follows
>
>  5 - git diff > tempchanges.patch
>  6 - git reset --hard # this will discard your changes, careful
>  7 - git checkout Y
>  8 - patch -p1 < tempchanges.patch
>
> The patch may not apply cleanly :-) -- note that patch is more
> tolerant of iffy merges than git's internal implementation ("git
> apply") -- so it will succeed more often... but the results need
> review.
>
> There is a more git-style approach that is to use git-stash -- it uses
> git-apply and may not do what you want. The steps are
>
>  5a - git stash # will save your changed files into a "stashed commit"
> and clear out the changes from your working copy
>  6a - git checkout Y
>  7a - git stash apply
>
> hth,
>
>
>
> m
> --
>  martin.langhoff@gmail.com
>  martin@laptop.org -- School Server Architect
>  - ask interesting questions
>  - don't get distracted with shiny stuff  - working code first
>  - http://wiki.laptop.org/go/User:Martinlanghoff
>

^ permalink raw reply

* Re: Commited to wrong branch
From: Martin Langhoff @ 2009-09-15 11:16 UTC (permalink / raw)
  To: Howard Miller; +Cc: git
In-Reply-To: <26ae428a0909150405v3087016fxee5ac98057868677@mail.gmail.com>

On Tue, Sep 15, 2009 at 1:05 PM, Howard Miller
<howard@e-learndesign.co.uk> wrote:
> I'm pretty shocked how difficult this is... still...

No prob. It's only hard at the beginning :-)

> I'm finding git logs and reflogs pretty difficult to read and
> interpret (head melting) - in particular telling what happened on what
> branch -

I found gitk enormously helpful to visualise things. Try

 gitk # will show you the current branch

 gitk X Y # will show you both branches

gitk is a ton easier to visualise. git log is pretty good but won't
show merges, so it's limited.

git reflog is confusing, but it's mostly a tool to help when there's
been a mess and you want to diagnose WTH happened...

>but looking at the reflog (which I assume is showing me the
> actions on the current branch, but I'm not sure)

Don't worry about the reflog...

>  I think I must have
> made two commits on the wrong branch so the reset has only 'popped'
> the top one. Other than that your interpretation is correct.

Ok, so looking at gitk, there would still be one "wrong" commit. Can
you confirm?

> I cannot currently change branches - it only complains about one file.

If you did follow my previous instructions (specially doing 'git reset
--hard'), then this should not happen. Except...

Except when you have a file that git is not tracking, and it exists in
the "other" branch. The commit you undid earlier probably added that
file. So just rm that file, and change branches.

> I'm a bit worried about that - I would like to understand why this is
> a problem but I don't.

About the file? It was "new" in the commit you un-committed. So when
you do git reset --hard, git makes sure all the files it is
_currently_ tracking are "unchanged". If that file was new, it ignores
it. Just rm it and be happy.

> So I am now a little hazy on how to deal with previous TWO commits.

Just review gitk and confirm if there are more commits to unstich --
and we'll  work from there


m
-- 
 martin.langhoff@gmail.com
 martin@laptop.org -- School Server Architect
 - ask interesting questions
 - don't get distracted with shiny stuff  - working code first
 - http://wiki.laptop.org/go/User:Martinlanghoff

^ permalink raw reply

* Re: Commited to wrong branch
From: Björn Steinbrink @ 2009-09-15 11:19 UTC (permalink / raw)
  To: Martin Langhoff; +Cc: Howard Miller, git
In-Reply-To: <46a038f90909150355h20b39c71w4af7e2be2920fdbb@mail.gmail.com>

On 2009.09.15 12:55:58 +0200, Martin Langhoff wrote:
> On Tue, Sep 15, 2009 at 12:31 PM, Howard Miller
> <howard@e-learndesign.co.uk> wrote:
> > I am resurrecting a discussion from a week or two back (been on
> > holiday).  As follows...
> >
> > I had made some changes to some files and then done a commit. Only
> > then did I realise that I had the wrong branch checked out. To make
> > matters worse I then did a 'git reset HEAD^' which means that I can
> > now no longer switch branches. I am stuck. I had some advice (thanks!)
> > but it was not complete. I'd appreciate some more help.
> 
> Hi Howard,
> 
> just to make sure I understand your issue
> 
>   1 - you were on branch X, thinking your were on branch Y
>   2 - edit, diff, commit, realised the mistake
>   3 - git reset HEAD^
> 
> so if you now run `git status` and `git diff` it will show your
> changes as if they were uncommitted and unstaged.

Not "as if", they are.

> (Before you start with various attempts to recover below, a great
> trick is to make an instant-backup in case things go wrong: cd .. / ;
> cp -pr moodle.git moodle-backup.git ; cd moodle.git )
> 
> You can now try do do
> 
>   4 - git checkout Y
> 
> and if the changes are on files that don't change between X and Y,
> then git will change the branches and keep your changes there. If the
> files are different between X and Y, it won't work.

Well, then you could use "git checkout -m Y", to have git try a
three-way merge (which might of course leave conflicts).

> What I can recommend is to save your patch, as follows
> 
>   5 - git diff > tempchanges.patch
>   6 - git reset --hard # this will discard your changes, careful
>   7 - git checkout Y
>   8 - patch -p1 < tempchanges.patch
> 
> The patch may not apply cleanly :-) -- note that patch is more
> tolerant of iffy merges than git's internal implementation ("git
> apply") -- so it will succeed more often... but the results need
> review.

But a lot worse than the usual 3-way merge stuff, like "checkout -m" or
"stash apply". The advantage of "stash" + "stash apply" is that, in case
of conflicts, you can easily retry to fix them over and over again,
while with "checkout -m", you can't easily start over AFAIK.

> There is a more git-style approach that is to use git-stash -- it uses
> git-apply and may not do what you want.

Only "stash apply --index" uses "git apply", and only to re-apply the
staged changes. The changes for the working tree are applied using a
3way merge.

Björn

^ permalink raw reply

* Re: Question about git-svn
From: Martin Larsson @ 2009-09-15 11:49 UTC (permalink / raw)
  To: Eric Wong; +Cc: git
In-Reply-To: <20090905060940.GB22272@dcvr.yhbt.net>

On Fri, 2009-09-04 at 23:09 -0700, Eric Wong wrote:
> martin liste larsson <martin.liste.larsson@gmail.com> wrote:
> > I have a problem using git-svn. Is this the right place to ask then?
> 
> Hi, Yes, feel free to Cc me directly as well.

Sorry for the long delay, your answer seemed to get lost in the
flood... :*)


> Just checking the obvious, you are running "git svn fetch", right?

It seemed the download terminated, for some reason. Running "git svn
fetch" again allowed it to continue. After a couple of days and
attempts, everything got downloaded. But it would be helpful if git told
me it had failed. As it was now, the end of a failed run looked like
this (a random selection):
...
r495 = da7253aa4d2af7d3349b36d917573e948ccd2828 (tags/DelfiRaadgiver-2.6.0-b9@1352)
        A       Kildekode/Script.deploy/deploy_all_webapps_utv.cmd
r496 = 28e21ba0098d7f7ae74f134af42fe8dc92718f56 (tags/DelfiRaadgiver-2.6.0-b9@1352)
        M       Kildekode/Database/data/kundespesifikk/fanasb/data_dr_aktivaklasser.sql
r497 = 58543e617e27bb7960e0b64ab2419edd90b5c56e (tags/DelfiRaadgiver-2.6.0-b9@1352)
        M       Kildekode/Moduler/DRBasis/src/java/no/delfidata/raad2/jdbo/func/RaadJDBOOpsImpl.java
r498 = e882fe24795addf8cecdeea9dcb82f1a49697e40 (tags/DelfiRaadgiver-2.6.0-b9@1352)
        M       Kildekode/Database/data/kundespesifikk/fanasb/data_ds_user.sql
r499 = e8f6b1350d2d6fcd7fe786f1aa4837e1f61cf8b3 (tags/DelfiRaadgiver-2.6.0-b9@1352)
        M       Kildekode/Database/dokumentasjon/raad_db_1_1.PDM
r500 = cd273927d38ed673c2ec895f641f322dc8818f9a (tags/DelfiRaadgiver-2.6.0-b9@1352)
Auto packing your repository for optimum performance. You may also
run "git gc" manually. See "git help gc" for more information.
Counting objects: 36, done.
Compressing objects: 100% (34/34), done.
Writing objects: 100% (36/36), done.
Total 36 (delta 10), reused 0 (delta 0)
Removing duplicate objects: 100% (256/256), done.
        M       Kildekode/Database/data/kundespesifikk/handelsbanken/data_ds_user.sql
r501 = 27fc97c162b9cf440ce8a5f6e8dea10354324309 (tags/DelfiRaadgiver-2.6.0-b9@1352)
        M       Kildekode/Database/data/kundespesifikk/sbm/data_dr_aktivaklasser.sql
r502 = 19d5cf2da05f7b92cb134c6ae83f6ffc5f3cde08 (tags/DelfiRaadgiver-2.6.0-b9@1352)
        M       Kildekode/Database/data/kundespesifikk/sbsoer/data_dr_aktivaklasser.sql
        M       Kildekode/Database/data/kundespesifikk/sbsoer/data_dr_aktivaklasser.xls
r503 = f73d7bb66e7bfe6a05647da371be477bf43d36e5 (tags/DelfiRaadgiver-2.6.0-b9@1352)
        A       Kildekode/Database/data/kundespesifikk/sdc/data_ds_user.sql
r504 = 8fdf43287207b4029679e4e86c405eabd2be6596 (tags/DelfiRaadgiver-2.6.0-b9@1352)
        A       Kildekode/Script.deploy/build_all_webapps_utv.xml
        M       Kildekode/Script.deploy/deploy_all_webapps_utv.cmd
r505 = d7a31939c0aed653540b471c8f5e464870fca5b1 (tags/DelfiRaadgiver-2.6.0-b9@1352)
        M       Kildekode/Script.deploy/build_all_webapps_utv.xml
r506 = 4ff67d714dedeed065c359376b7d055d67a4c02b (tags/DelfiRaadgiver-2.6.0-b9@1352)
martin@martin:~/Arbeid/git-rpm$ 

There's no real indication that this failed. But "git branch -a" doesn't
list 'master'.

However, as I said, repeating "git svn fetch" until very tired, made it
finally work...

M.

^ permalink raw reply

* Re: Patches for git-push --confirm and --show-subjects
From: Owen Taylor @ 2009-09-15 11:50 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Daniel Barkalow, git
In-Reply-To: <7v1vm892ow.fsf@alter.siamese.dyndns.org>

On Mon, 2009-09-14 at 22:50 -0700, Junio C Hamano wrote:

> You might not see a "policy" in your approach, but it makes some troubling
> hardcoded policy decisions.  Here are a few examples of what your patch
> decides, and makes it harder for other people to build on (rather, "around):
> 
>  - We support only interactive validation (confirmation).  If you want to
>    have an unattended validation scheme, there is no way to enhance the
>    mechanism this patch adds to do so.  You instead need to add yet
>    another command line option and hook into the same place as this patch
>    touches.

It seems like the bulk of any patch is going to be creating a clean
position in the code to do confirmation.

>  - We assume "git push" is run from terminal, and the only kind of
>    interactive validation we support is via typed confirmation from a line
>    terminal "[Y/n]?"  If you want to run "git push" from a GUI frontend
>    and have the user interact with a dialog window popped up separately,
>    you are also out of luck.

That's an interesting situation to consider. How do you see a pre-push
hook being used for that?

>  - We assume it is good enough to have various built-in presentations of
>    supporting information while asking for confirmations; there is no way
>    for casual end users to customize and enhance it.

A shell script that duplicates the display logic from transport.c while
interleaving nicely abbreviated bits of log will be on the complex side.
Is forking and modifying such a script going to be approachable for
casual end users?

- Owen

^ permalink raw reply

* [PATCH 1/2] Work around leftover temporary save file.
From: Pat Thoyts @ 2009-09-15  9:26 UTC (permalink / raw)
  To: git; +Cc: Alexy Borzenkov, Paul Mackerras
In-Reply-To: <1252437756-81986-1-git-send-email-snaury@gmail.com>


If a file exists and is hidden on Windows the Tcl open command will
fail as the attributes provided in the CREAT call fail to match those
of the existing file. Forcing removal of the temporary file before we
begin solves any problems caused by previous failures to save the
application settings. An alternative would be to remove the hidden
attribute before calling 'open'.

Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
---
 gitk |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/gitk b/gitk
index 1306178..a0214b7 100755
--- a/gitk
+++ b/gitk
@@ -2526,6 +2526,7 @@ proc savestuff {w} {
     if {$stuffsaved} return
     if {![winfo viewable .]} return
     catch {
+	if {[file exists ~/.gitk-new]} {file delete -force ~/.gitk-new}
 	set f [open "~/.gitk-new" w]
 	if {$::tcl_platform(platform) eq {windows}} {
 	    file attributes "~/.gitk-new" -hidden true
-- 
1.6.4.msysgit.0

^ permalink raw reply related

* [PATCH 2/2] Fix the geometry when restoring from zoomed state.
From: Pat Thoyts @ 2009-09-15  9:37 UTC (permalink / raw)
  To: git; +Cc: Alexy Borzenkov, Paul Mackerras
In-Reply-To: <1252437756-81986-1-git-send-email-snaury@gmail.com>


The patch to handle the geometry of a restored gitk by Alexy Borzenkov
causes the position of the columns to creep each time the application
is restarted. This patch addresses this by remembering the application
geometry for the normal state and saving that regardless of the actual
state when the application is closed.

Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
---
 gitk |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/gitk b/gitk
index a0214b7..67122c3 100755
--- a/gitk
+++ b/gitk
@@ -2251,6 +2251,8 @@ proc makewindow {} {
 	    }
 	    wm geometry . "${w}x$h"
 	}
+    } else {
+	set geometry(main) [wm geometry .]
     }
 
     if {[info exists geometry(state)] && $geometry(state) eq "zoomed"} {
@@ -2265,6 +2267,11 @@ proc makewindow {} {
         set ::BM "2"
     }
 
+    bind . <Configure> {
+	if {[winfo toplevel %W] eq "%W" && [wm state %W] eq "normal"} {
+	    set ::geometry(main) %wx%h+%x+%y
+	}
+    }
     bind .pwbottom <Configure> {resizecdetpanes %W %w}
     pack .ctop -fill both -expand 1
     bindall <1> {selcanvline %W %x %y}
@@ -2556,7 +2563,7 @@ proc savestuff {w} {
 	puts $f [list set extdifftool $extdifftool]
 	puts $f [list set perfile_attrs $perfile_attrs]
 
-	puts $f "set geometry(main) [wm geometry .]"
+	puts $f "set geometry(main) $::geometry(main)"
 	puts $f "set geometry(state) [wm state .]"
 	puts $f "set geometry(topwidth) [winfo width .tf]"
 	puts $f "set geometry(topheight) [winfo height .tf]"
-- 
1.6.4.msysgit.0

^ permalink raw reply related

* Re: Commited to wrong branch
From: Howard Miller @ 2009-09-15 12:10 UTC (permalink / raw)
  To: Martin Langhoff; +Cc: git
In-Reply-To: <46a038f90909150416h60ea7d74xd2337fe50f603dcb@mail.gmail.com>

Martin,

Looked at gitk - yes there is definitely one more commit still on the
current (wrong) branch.

I deleted the offending file and have now successfully switched to the
other (correct) branch.

Howard

2009/9/15 Martin Langhoff <martin.langhoff@gmail.com>:
> On Tue, Sep 15, 2009 at 1:05 PM, Howard Miller
> <howard@e-learndesign.co.uk> wrote:
>> I'm pretty shocked how difficult this is... still...
>
> No prob. It's only hard at the beginning :-)
>
>> I'm finding git logs and reflogs pretty difficult to read and
>> interpret (head melting) - in particular telling what happened on what
>> branch -
>
> I found gitk enormously helpful to visualise things. Try
>
>  gitk # will show you the current branch
>
>  gitk X Y # will show you both branches
>
> gitk is a ton easier to visualise. git log is pretty good but won't
> show merges, so it's limited.
>
> git reflog is confusing, but it's mostly a tool to help when there's
> been a mess and you want to diagnose WTH happened...
>
>>but looking at the reflog (which I assume is showing me the
>> actions on the current branch, but I'm not sure)
>
> Don't worry about the reflog...
>
>>  I think I must have
>> made two commits on the wrong branch so the reset has only 'popped'
>> the top one. Other than that your interpretation is correct.
>
> Ok, so looking at gitk, there would still be one "wrong" commit. Can
> you confirm?
>
>> I cannot currently change branches - it only complains about one file.
>
> If you did follow my previous instructions (specially doing 'git reset
> --hard'), then this should not happen. Except...
>
> Except when you have a file that git is not tracking, and it exists in
> the "other" branch. The commit you undid earlier probably added that
> file. So just rm that file, and change branches.
>
>> I'm a bit worried about that - I would like to understand why this is
>> a problem but I don't.
>
> About the file? It was "new" in the commit you un-committed. So when
> you do git reset --hard, git makes sure all the files it is
> _currently_ tracking are "unchanged". If that file was new, it ignores
> it. Just rm it and be happy.
>
>> So I am now a little hazy on how to deal with previous TWO commits.
>
> Just review gitk and confirm if there are more commits to unstich --
> and we'll  work from there
>
>
> m
> --
>  martin.langhoff@gmail.com
>  martin@laptop.org -- School Server Architect
>  - ask interesting questions
>  - don't get distracted with shiny stuff  - working code first
>  - http://wiki.laptop.org/go/User:Martinlanghoff
>

^ permalink raw reply

* put in scripts
From: Michael.Kraemer @ 2009-09-15 12:16 UTC (permalink / raw)
  To: git


hello,

How i can put in this script in GIT?
(http://git.or.cz/gitwiki/ExampleScripts#Settingthetimestampsofthefilestothecommittimestampofthecommitwhichlasttouchedthem
 )
I need the "last commit time" function like in SVN.
THANKS

EISENMANN AG
i.A. Michael Krämer
Postfach 1280 - 71002 Böblingen
Tübinger Straße 81 - 71032 Böblingen
E-Mail:     Michael.Kraemer@eisenmann.com
Internet:   http://www.eisenmann.com

_________________________________________________________________________

Sitz: Böblingen, AG Stuttgart HRB 245891
USt.-IdNr.: DE 145 141 533
Vorstand: Dr. Matthias von Krauland (Sprecher), Dr. Thomas Beck, Dr.
Kersten Christoph Link
Vorsitzender des Aufsichtsrates: Peter Eisenmann


Diese E-Mail sowie etwaige Anlagen sind ausschließlich für den Adressaten
bestimmt und können vertrauliche oder gesetzlich geschützte Informationen
enthalten. Wenn Sie nicht der bestimmungsgemäße Empfänger sind,
unterrichten Sie bitte den Absender und vernichten Sie diese Mail.
Anderen als dem bestimmungsgemäßen Adressaten ist es untersagt, diese
E-Mail zu speichern, weiterzuleiten oder ihren Inhalt, auf welche Weise
auch immer, zu verwenden. Wir verwenden aktuelle Virenschutzprogramme.
Für Schäden, die dem Empfänger gleichwohl durch von uns zugesandte, mit
Viren befallene E-Mails entstehen, schließen wir jede Haftung aus.

The information contained in this e-mail or attachments is intended only
for its addressee and may contain confidential and/or privileged
information. If you have received this e-mail in error, please notify
the sender and delete the e-mail. If you are not the intended recipient,
you are hereby notified, that  saving, distribution or use of the
content of this e-mail in any way is prohibited. We use updated virus
protection software. We do not accept any responsibility for damages
caused anyhow by viruses transmitted via e-mail.

^ permalink raw reply

* Re: Commited to wrong branch
From: Martin Langhoff @ 2009-09-15 12:46 UTC (permalink / raw)
  To: Howard Miller; +Cc: git
In-Reply-To: <26ae428a0909150510n56b1d4eg6565a6cca8c9b46c@mail.gmail.com>

On Tue, Sep 15, 2009 at 2:10 PM, Howard Miller
<howard@e-learndesign.co.uk> wrote:
> Martin,
>
> Looked at gitk - yes there is definitely one more commit still on the
> current (wrong) branch.
>
> I deleted the offending file and have now successfully switched to the
> other (correct) branch.

ok!

so you have

A - The commit you undid, and have in the temp patch. Note that this
patch file is missing the file you've rm'd.

B - A commit you haven't "undone" on the "wrong" branch X.

 and you are on branch Y

so now...

1 - git format-patch Y^..Y  # will export that patch B into a file for you.
2 - git am 0001-whatever-the-name-of-the-file.txt # patch B
    this may need conflict resolution - read the notes it prints! If
it refuses to apply the patch, do "git am --skip" to indicate you
won't use git-am no more for this, and try applying it with the patch
utility.
3 - patch -p1 < your-patch-A.patch
4 - find and readd the file you rm'd earlier -- if you don't have
another copy, we can get it from git reflog but that'll take extra
steps :-)
5 - git commit # you're committing your patch A here

Now, review with gitk to see that you have what you want to have
there. If it's all ok...

 6 - git checkout X
 7 - git reset --hard # unstich that last stray commit
   --

hope the above helps. Git pros will see that the process could be much
shorter :-) I chose this specific path because in exporting your
patches and applying them again you can see each step.

If we were to start again, and the branches are reasonably close to
eachother (not 19_STABLE vs cvshead :-) ) then you can say

 - X has 2 bad commits that belong to Y, then
 1 - gitk X & # open gitk to visualise the commits, send it to the background
 2 - git checkout Y
 3 - git cherry-pick X^ # takes the next-to-last commit from X and
tries to apply it here - conflict resolution may be needed
 4 - git cherry-pick X # same with the very last commit on X
 5 - gitk # check that is all as you want it
 6 - git checkout X
 7 - git reset --hard X^^ # "rewind 2 commits"

hth,



m
-- 
 martin.langhoff@gmail.com
 martin@laptop.org -- School Server Architect
 - ask interesting questions
 - don't get distracted with shiny stuff  - working code first
 - http://wiki.laptop.org/go/User:Martinlanghoff

^ permalink raw reply

* Re: [PATCH] gitk: restore wm state to normal before saving geometry  information
From: Alexey Borzenkov @ 2009-09-15 12:54 UTC (permalink / raw)
  To: Pat Thoyts; +Cc: git
In-Reply-To: <87eiq8ct40.fsf@users.sourceforge.net>

On Tue, Sep 15, 2009 at 4:03 PM, Pat Thoyts
<patthoyts@users.sourceforge.net> wrote:
>>gitk now includes patches for saving and restoring wm state, however
>>because it saves wm geometry when window can still be maximized the
>>maximize/restore button becomes useless after restarting gitk (you
>>will get a huge displaced window if you try to restore it). This
>>patch fixes this issue by storing window geometry in normal state.
> I tried this patch on windows and I find that it causes the columns in
> the top view to creep each time you restart the application. This is I
> think due to the way this patch sets the state to normal before
> recording all the settings.


This is strange, as I certainly don't see this behaviour now (I'm
using gitk in version 1.6.4.3). Actually, I did see that behaviour
once, but I believe this was when I ran an unpatched gitk which seemed
to record wrong geometry. As soon as I cleared ~/.gitk of those wrong
coordinates I haven't seen this behaviour anymore.

On the other hand, when I resize columns and then maximize/restore the
window repeatedly I see that their sizes change in a strange way (and
the smaller restored window they stranger are results) until hitting
some sort of equilibrium, then maximize/restore doesn't have effect on
their sizes anymore. So maybe there's a bug not in a way my patch
restores the window, but in a way window resizes are handled.


> I will post an alternative patch that records the normal geometry
> whenever it changes instead which seems to work better for me.


By all means.

^ permalink raw reply


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