Git development
 help / color / mirror / Atom feed
* Re: [PATCH 2/4] apply: apply works outside a repository
From: Junio C Hamano @ 2009-11-22 17:28 UTC (permalink / raw)
  To: Björn Gustavsson; +Cc: git
In-Reply-To: <4B0964A1.2040302@gmail.com>

Björn Gustavsson <bgustavsson@gmail.com> writes:

> The documentation for 'git apply' talks about applying a
> patch/diff to the index and to the working tree, which seems
> to imply that it will not work outside a git repository.

Thanks.  I think the headline should also be reworded.  It currently
reads:

    Apply a patch on a git index file and/or a working tree

but historically and still in real life practices, when you use apply (as
opposed to am), you apply primarily to the files and optionally to the
index, so this should read something like:

    Apply a patch to files and/or to the index

We could say "to files in the work tree", but that would give a wrong
impression that the files we talk about must be in a directory that is
part of the work tree of some repository, so it probably is better without
it.

The same comment applies to the beginning of the DESCRIPTION section.  I
actually think your added text should reword the current two-liner there,
instead of being added at the bottom.  Here is my attempt.

    Reads supplied diff output (iow "a patch"), and applies it to files.
    With --index (--cache) options, the patch is also (only) applied to
    the index respectively.  Without these options, the command applies
    the patch only to files, and does not require them to be in a git
    repository.

^ permalink raw reply

* Re: [PATCH] send-email: new 'add-envelope' option
From: Junio C Hamano @ 2009-11-22 17:54 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: Jeff King, git
In-Reply-To: <94a0d4530911220403w7238dab7saf18830a89f2add5@mail.gmail.com>

Felipe Contreras <felipe.contreras@gmail.com> writes:

> Maybe I should wait until somebody adds the tests to --envelope-sender
> before pushing this patch.

You can say that if you want to be difficult to work with, or you can be
that somebody yourself and make a difference.

Let me show you that we can be constructive for a change ;-)

How about something trivial like this?

-- >8 --
Subject: [PATCH] t9001: test --envelope-sender option of send-email

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/t9001-send-email.sh |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 84a7f03..004e81c 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -95,6 +95,23 @@ test_expect_success \
     'Verify commandline' \
     'test_cmp expected commandline1'
 
+test_expect_success 'Send patches with --envelope-sender' '
+    clean_fake_sendmail &&
+     git send-email --envelope-sender="Patch Contributer <patch@example.com>" --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
+'
+
+cat >expected <<\EOF
+!patch@example.com!
+!-i!
+!nobody@example.com!
+!author@example.com!
+!one@example.com!
+!two@example.com!
+EOF
+test_expect_success \
+    'Verify commandline' \
+    'test_cmp expected commandline1'
+
 cat >expected-show-all-headers <<\EOF
 0001-Second.patch
 (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'

^ permalink raw reply related

* [PATCH 0/4] Documentation update (mainly for apply)
From: Björn Gustavsson @ 2009-11-22 19:35 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

Here is my updated patch series based on Junio's feedback.

The first patch now also updates the description of -z
for the log and diff* commands.

The second patch has better wording based on Junio's
suggestion.

I have swapped patch 3 and 4 so that the "working tree"
patch comes last, to make it easier to replace or drop.

Björn Gustavsson (4):
  Clarify and correct -z
  apply: apply works outside a repository
  apply: Format all options using back-quotes
  apply: Use the term "working tree" consistently

 Documentation/diff-options.txt |   17 +++++++++++++--
 Documentation/git-apply.txt    |   41 ++++++++++++++++++++++-----------------
 2 files changed, 37 insertions(+), 21 deletions(-)

^ permalink raw reply

* [PATCH 1/4] Clarify and correct -z
From: Björn Gustavsson @ 2009-11-22 19:43 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

The description for -z is too vague and general for the
apply, diff*, and log commands.

Change the description of -z for 'git log' to note that
commits will be separated by NULs.

Change the description of -z for 'git diff*' and 'git apply'
to note that it applies to the --numstat option, and for
'git diff*' also for --raw option.

Also correct the description of the "munging" of pathanmes that
takes place in the absence of -z for the 'git diff*' and
'git apply' commands, namely that apart from the characters mentioned,
double quotes will also be escaped and that the pathname will be
enclosed in double quotes if any characters are escaped.

Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>
---
The original documentation for -z in diff-options.txt says:

"Also output from commands such as `git-log` will be delimited
with NUL between commits."

I am not sure about "such as git-log". What other command would
that be? In my patch, I have assumed that only 'git log' behaves
in that way (i.e. that it is the only command -z will change
the behavior of even when no other options are given).


 Documentation/diff-options.txt |   17 ++++++++++++++---
 Documentation/git-apply.txt    |   12 +++++++-----
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 2b37193..18366b1 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -85,10 +85,21 @@ ifndef::git-format-patch[]
 endif::git-format-patch[]
 
 ifndef::git-format-patch[]
+
 -z::
-	NUL-line termination on output.  This affects the `--raw`
-	output field terminator.  Also output from commands such
-	as `git-log` will be delimited with NUL between commits.
+ifndef::git-log[]
+	When `--raw` or `--numstat` has been given, do not munge
+	pathnames and use NULs as output field terminators.
++
+Without this option, each pathname output will have TAB, LF, double quotes,
+and backslash characters replaced with `\t`, `\n`, `\"`, and `\\`,
+respectively, and the pathname will be enclosed in double quotes if
+any of those replacements occurred.
+endif::git-log[]
+
+ifdef::git-log[]
+	Separate the commits with NULs instead of with new newlines.
+endif::git-log[]
 
 --name-only::
 	Show only names of changed files.
diff --git a/Documentation/git-apply.txt b/Documentation/git-apply.txt
index 5ee8c91..0156ca9 100644
--- a/Documentation/git-apply.txt
+++ b/Documentation/git-apply.txt
@@ -87,11 +87,13 @@ the information is read from the current index instead.
 	rejected hunks in corresponding *.rej files.
 
 -z::
-	When showing the index information, do not munge paths,
-	but use NUL terminated machine readable format.  Without
-	this flag, the pathnames output will have TAB, LF, and
-	backslash characters replaced with `\t`, `\n`, and `\\`,
-	respectively.
+	When `--numstat` has been given, do not munge pathnames,
+	but use a NUL-terminated machine-readable format.
++
+Without this option, each pathname output will have TAB, LF, double quotes,
+and backslash characters replaced with `\t`, `\n`, `\"`, and `\\`,
+respectively, and the pathname will be enclosed in double quotes if
+any of those replacements occurred.
 
 -p<n>::
 	Remove <n> leading slashes from traditional diff paths. The
-- 
1.6.5.3.298.g39add

^ permalink raw reply related

* [PATCH 2/4] apply: apply works outside a repository
From: Björn Gustavsson @ 2009-11-22 19:43 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

The documentation for 'git apply' talks about applying a
patch/diff to the index and to the working tree, which seems
to imply that it will not work outside a git repository.

Actually 'git patch' works outside a repository (which can
be useful especially for applying binary or rename patches that
the standard "patch" utility cannot handle), so the documentation
should mention it.

Thanks to Junio for suggesting better wording.

Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>
---
 Documentation/git-apply.txt |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/Documentation/git-apply.txt b/Documentation/git-apply.txt
index 0156ca9..0c55ca9 100644
--- a/Documentation/git-apply.txt
+++ b/Documentation/git-apply.txt
@@ -3,7 +3,7 @@ git-apply(1)
 
 NAME
 ----
-git-apply - Apply a patch on a git index file and/or a working tree
+git-apply - Apply a patch to files and/or to the index
 
 
 SYNOPSIS
@@ -20,8 +20,11 @@ SYNOPSIS
 
 DESCRIPTION
 -----------
-Reads supplied 'diff' output and applies it on a git index file
-and a work tree.
+Reads the supplied diff output (i.e. "a patch") and applies it to files.
+With the `--index` option the patch is also applied to the index, and
+with the `--cache` option the patch is only applied to the index.
+Without these options, the command applies the patch only to files,
+and does not require them to be in a git repository.
 
 OPTIONS
 -------
-- 
1.6.5.3.298.g39add

^ permalink raw reply related

* [PATCH 3/4] apply: Format all options using back-quotes
From: Björn Gustavsson @ 2009-11-22 19:43 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>
---
 Documentation/git-apply.txt |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/Documentation/git-apply.txt b/Documentation/git-apply.txt
index 0c55ca9..6a07ec2 100644
--- a/Documentation/git-apply.txt
+++ b/Documentation/git-apply.txt
@@ -37,7 +37,7 @@ OPTIONS
 	input.  Turns off "apply".
 
 --numstat::
-	Similar to \--stat, but shows the number of added and
+	Similar to `--stat`, but shows the number of added and
 	deleted lines in decimal notation and the pathname without
 	abbreviation, to make it more machine friendly.  For
 	binary files, outputs two `-` instead of saying
@@ -55,7 +55,7 @@ OPTIONS
 	file and detects errors.  Turns off "apply".
 
 --index::
-	When --check is in effect, or when applying the patch
+	When `--check` is in effect, or when applying the patch
 	(which is the default when none of the options that
 	disables it is in effect), make sure the patch is
 	applicable to what the current index file records.  If
@@ -66,7 +66,7 @@ OPTIONS
 --cached::
 	Apply a patch without touching the working tree. Instead take the
 	cached data, apply the patch, and store the result in the index
-	without using the working tree. This implies '--index'.
+	without using the working tree. This implies `--index`.
 
 --build-fake-ancestor=<file>::
 	Newer 'git-diff' output has embedded 'index information'
@@ -112,8 +112,8 @@ any of those replacements occurred.
 	By default, 'git-apply' expects that the patch being
 	applied is a unified diff with at least one line of context.
 	This provides good safety measures, but breaks down when
-	applying a diff generated with --unified=0. To bypass these
-	checks use '--unidiff-zero'.
+	applying a diff generated with `--unified=0`. To bypass these
+	checks use `--unidiff-zero`.
 +
 Note, for the reasons stated above usage of context-free patches is
 discouraged.
@@ -149,7 +149,7 @@ discouraged.
 	be useful when importing patchsets, where you want to include certain
 	files or directories.
 +
-When --exclude and --include patterns are used, they are examined in the
+When `--exclude` and `--include` patterns are used, they are examined in the
 order they appear on the command line, and the first match determines if a
 patch to each path is used.  A patch to a path that does not match any
 include/exclude pattern is used by default if there is no include pattern
@@ -232,13 +232,13 @@ Submodules
 If the patch contains any changes to submodules then 'git-apply'
 treats these changes as follows.
 
-If --index is specified (explicitly or implicitly), then the submodule
+If `--index` is specified (explicitly or implicitly), then the submodule
 commits must match the index exactly for the patch to apply.  If any
 of the submodules are checked-out, then these check-outs are completely
 ignored, i.e., they are not required to be up-to-date or clean and they
 are not updated.
 
-If --index is not specified, then the submodule commits in the patch
+If `--index` is not specified, then the submodule commits in the patch
 are ignored and only the absence or presence of the corresponding
 subdirectory is checked and (if possible) updated.
 
-- 
1.6.5.3.298.g39add

^ permalink raw reply related

* [PATCH 4/4] apply: Use the term "working tree" consistently
From: Björn Gustavsson @ 2009-11-22 19:53 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

The documentation for 'git apply' uses both the terms
"work tree" and "working tree". Since the glossary uses
the term "working tree", change all occurrences of
"work tree" to "working tree".

Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>
---
Junio wrote that he personally would vote for changing
it the other way around starting from the glossary.

"Work tree" feels fine for me (and is shorter than
"working tree"), but I am not a native speaker.

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

diff --git a/Documentation/git-apply.txt b/Documentation/git-apply.txt
index 6a07ec2..c2528a7 100644
--- a/Documentation/git-apply.txt
+++ b/Documentation/git-apply.txt
@@ -51,7 +51,7 @@ OPTIONS
 
 --check::
 	Instead of applying the patch, see if the patch is
-	applicable to the current work tree and/or the index
+	applicable to the current working tree and/or the index
 	file and detects errors.  Turns off "apply".
 
 --index::
@@ -59,7 +59,7 @@ OPTIONS
 	(which is the default when none of the options that
 	disables it is in effect), make sure the patch is
 	applicable to what the current index file records.  If
-	the file to be patched in the work tree is not
+	the file to be patched in the working tree is not
 	up-to-date, it is flagged as an error.  This flag also
 	causes the index file to be updated.
 
-- 
1.6.5.3.298.g39add

^ permalink raw reply related

* 'error: unable to set permission to './objects/...'
From: Rafal Rusin @ 2009-11-22 20:02 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 557 bytes --]

Hello,

I'm hosting git repository on filesystem with 'chmod <some-file>'
causing permission denied error (it's smbfs mounted directory),
When I was doing push to such repo using file:// protocol, I got
following error:
error: unable to set permission to './objects/...'

I did a small fix to sha1_file.c (patch in attachment) and git now
warns when unable to chmod, and continues push. This resolved problem.
What do you think about applying it?

Regards,
-- 
Rafał Rusin
http://rrusin.blogspot.com
http://www.touk.pl
http://top.touk.pl

[-- Attachment #2: permission.patch --]
[-- Type: text/x-diff, Size: 449 bytes --]

diff --git a/sha1_file.c b/sha1_file.c
index 4ea0b18..305e751 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2272,8 +2272,9 @@ int move_temp_to_file(const char *tmpfile, const char *filename)
 	}
 
 out:
-	if (set_shared_perm(filename, (S_IFREG|0444)))
-		return error("unable to set permission to '%s'", filename);
+	if (set_shared_perm(filename, (S_IFREG|0444))) {
+		warning("unable to set permission to '%s'", filename);
+    }
 	return 0;
 }
 

^ permalink raw reply related

* [PATCH] Fix truncated usage messages
From: Björn Gustavsson @ 2009-11-22 21:19 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

The usage messages for some commands (such as 'git diff-tree')
are truncated because they don't fit in a fixed buffer of
1024 bytes.

It would be tempting to eliminate the buffer and the problem once
and for all by doing the output in three steps, but doing so could
(according to commit d048a96e) increase the likelyhood of messing
up the display.

So we just increase the size of the buffer.

Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>
---
 usage.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/usage.c b/usage.c
index e307e01..79856a2 100644
--- a/usage.c
+++ b/usage.c
@@ -7,7 +7,7 @@
 
 static void report(const char *prefix, const char *err, va_list params)
 {
-	char msg[1024];
+	char msg[4096];
 	vsnprintf(msg, sizeof(msg), err, params);
 	fprintf(stderr, "%s%s\n", prefix, msg);
 }
-- 
1.6.5.3.298.g39add

^ permalink raw reply related

* Re: 'error: unable to set permission to './objects/...'
From: Miklos Vajna @ 2009-11-22 22:09 UTC (permalink / raw)
  To: Rafal Rusin; +Cc: git
In-Reply-To: <9bbf67fa0911221202r605de38coc2496b1f09123725@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 373 bytes --]

On Sun, Nov 22, 2009 at 09:02:12PM +0100, Rafal Rusin <rafal.rusin@gmail.com> wrote:
> I did a small fix to sha1_file.c (patch in attachment) and git now
> warns when unable to chmod, and continues push. This resolved problem.
> What do you think about applying it?

Please read Documentation/SubmittingPatches, patches should be sent
inline and with a Signed-off-by line.

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply

* Re: [PATCH 1/2] merge-recursive: point the user to commit when file would be overwritten.
From: Matthieu Moy @ 2009-11-22 22:09 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7vskc9vzqg.fsf@alter.siamese.dyndns.org>

Junio C Hamano <gitster@pobox.com> writes:

> Matthieu Moy <Matthieu.Moy@imag.fr> writes:
>
>> The commit-before-pull is well accepted in the DVCS community, but is
>> confusing some new users. This should get them back in the right way when
>> the problem occurs.
>>
>> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
>
> Don't these extra lines warrant "advice.*" option?

I was thinking this would be overkill for a one-line advice, but it
doesn't harm to provide the option. I'll resend the patch with it
(it's not _as_ straightforward as it seems to be since the initial
structure is static in the function, but still reasonable).

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply

* Re: [PATCH 2/2] user-manual: Document that "git merge" doesn't like uncommited changes.
From: Matthieu Moy @ 2009-11-22 22:18 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7vk4xlvtib.fsf@alter.siamese.dyndns.org>

Junio C Hamano <gitster@pobox.com> writes:

> "but not the working tree itself" is not incorrect per-se, but misses the
> point.  How about...
>
> 	A merge is made by combining the changes made in "branchname" and
>         the changes made up to the latest commit in your current branch
>         since their histories forke.  The work tree is overwritten by the
>         result of the merge when this combining is done cleanly, or
>         overwritten by a half-merged results when this combining results
>         in conflicts.  Therefore, ...

Maybe better. OTOH, it reveals another problem: Your "the work tree is
overwritten by ..." tend to imply that the result is not commited,
while the normal case is indeed to create a merge commit
automatically.

In its current state, the doc jumps to conflict resolution and how to
commit after resolving them without saying "oh, normally this is over,
Git did the commit for you". And for people comming from SVN, thinking
"merge = update", it's not obvious at all that a merge should result
in a commit.

So, I'll resend with one more paragraph talking about autocommit.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply

* [PATCH 2/2 v2] user-manual: Document that "git merge" doesn't like uncommited changes.
From: Matthieu Moy @ 2009-11-22 22:26 UTC (permalink / raw)
  To: git, gitster; +Cc: Matthieu Moy
In-Reply-To: <1258732767-12741-1-git-send-email-Matthieu.Moy@imag.fr>

We explain the user why uncommited changes can be problematic with merge,
and point to "commit" and "stash" for the solution. While talking about
commited Vs uncommited changes, we also make it clear that the result of
a merge is normally commited.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 Documentation/user-manual.txt |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt
index 269ec47..c09f4b2 100644
--- a/Documentation/user-manual.txt
+++ b/Documentation/user-manual.txt
@@ -1183,7 +1183,23 @@ $ git merge branchname
 -------------------------------------------------
 
 merges the development in the branch "branchname" into the current
-branch.  If there are conflicts--for example, if the same file is
+branch.
+
+A merge is made by combining the changes made in "branchname" and the
+changes made up to the latest commit in your current branch since
+their histories forked. The work tree is overwritten by the result of
+the merge when this combining is done cleanly, or overwritten by a
+half-merged results when this combining results in conflicts.
+Therefore, if you have uncommitted changes touching the same files as
+the ones impacted by the merge, Git will refuse to proceed. Most of
+the time, you will want to commit your changes before you can merge,
+and if you don't, then linkgit:git-stash[1] can take these changes
+away while you're doing the merge, and reapply them afterwards.
+
+If the changes are independant enough, Git will automatically complete
+the merge and commit the result (or reuse an existing commit in case
+of <<fast-forwards,fast-forward>>, see below). On the other hand,
+if there are conflicts--for example, if the same file is
 modified in two different ways in the remote branch and the local
 branch--then you are warned; the output may look something like this:
 
@@ -1679,7 +1695,7 @@ Sharing development with others
 Getting updates with git pull
 -----------------------------
 
-After you clone a repository and make a few changes of your own, you
+After you clone a repository and commit a few changes of your own, you
 may wish to check the original repository for updates and merge them
 into your own work.
 
-- 
1.6.5.3.435.g5f2e3.dirty

^ permalink raw reply related

* [PATCH 1/2 v2] merge-recursive: point the user to commit when file would be overwritten.
From: Matthieu Moy @ 2009-11-22 22:26 UTC (permalink / raw)
  To: git, gitster; +Cc: Matthieu Moy
In-Reply-To: <1258732767-12741-1-git-send-email-Matthieu.Moy@imag.fr>

The commit-before-pull is well accepted in the DVCS community, but is
confusing some new users. This should get them back in the right way when
the problem occurs.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 Documentation/config.txt |    4 ++++
 advice.c                 |    2 ++
 advice.h                 |    1 +
 merge-recursive.c        |    8 +++++++-
 4 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 13871a6..f481f8d 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -126,6 +126,10 @@ advice.*::
 		Directions on how to stage/unstage/add shown in the
 		output of linkgit:git-status[1] and the template shown
 		when writing commit messages. Default: true.
+	commitBeforeMerge::
+		Advice shown when linkgit:git-merge[1] refuses to
+		merge to avoid overwritting local changes.
+		Default: true.
 --
 
 core.fileMode::
diff --git a/advice.c b/advice.c
index ae4b1e8..cb666ac 100644
--- a/advice.c
+++ b/advice.c
@@ -2,6 +2,7 @@
 
 int advice_push_nonfastforward = 1;
 int advice_status_hints = 1;
+int advice_commit_before_merge = 1;
 
 static struct {
 	const char *name;
@@ -9,6 +10,7 @@ static struct {
 } advice_config[] = {
 	{ "pushnonfastforward", &advice_push_nonfastforward },
 	{ "statushints", &advice_status_hints },
+	{ "commitbeforemerge", &advice_commit_before_merge },
 };
 
 int git_default_advice_config(const char *var, const char *value)
diff --git a/advice.h b/advice.h
index e9df8e0..3de5000 100644
--- a/advice.h
+++ b/advice.h
@@ -3,6 +3,7 @@
 
 extern int advice_push_nonfastforward;
 extern int advice_status_hints;
+extern int advice_commit_before_merge;
 
 int git_default_advice_config(const char *var, const char *value);
 
diff --git a/merge-recursive.c b/merge-recursive.c
index f55b7eb..1870448 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -3,6 +3,7 @@
  * Fredrik Kuivinen.
  * The thieves were Alex Riesen and Johannes Schindelin, in June/July 2006
  */
+#include "advice.h"
 #include "cache.h"
 #include "cache-tree.h"
 #include "commit.h"
@@ -170,7 +171,7 @@ static int git_merge_trees(int index_only,
 	int rc;
 	struct tree_desc t[3];
 	struct unpack_trees_options opts;
-	static const struct unpack_trees_error_msgs msgs = {
+	struct unpack_trees_error_msgs msgs = {
 		/* would_overwrite */
 		"Your local changes to '%s' would be overwritten by merge.  Aborting.",
 		/* not_uptodate_file */
@@ -182,6 +183,11 @@ static int git_merge_trees(int index_only,
 		/* bind_overlap -- will not happen here */
 		NULL,
 	};
+	if (advice_commit_before_merge) {
+		msgs.would_overwrite = msgs.not_uptodate_file =
+			"Your local changes to '%s' would be overwritten by merge.  Aborting.\n"
+			"Please, commit your changes or stash them before you can merge.";
+	}
 
 	memset(&opts, 0, sizeof(opts));
 	if (index_only)
-- 
1.6.5.3.435.g5f2e3.dirty

^ permalink raw reply related

* Re: git-svn: Fails to drop leading path from empty dir name
From: Eric Wong @ 2009-11-22 23:25 UTC (permalink / raw)
  To: Björn Steinbrink; +Cc: git
In-Reply-To: <20091122134638.GA12233@atjola.homenet>

Björn Steinbrink <B.Steinbrink@gmx.de> wrote:
> Hi Eric,
> 
> the stuff to create empty directories fails to strip leading path
> components, e.g. when using
> "git svn clone -s svn://whatever/project/trunk".
> 
> Instead of creating the empty directory "foo" in the repo root, it
> creates "project/trunk/foo".
> 
> Ad hoc patch for the test case below.
> 
> Björn
> 
> diff --git a/t/t9146-git-svn-empty-dirs.sh b/t/t9146-git-svn-empty-dirs.sh
> index 5948544..9e22089 100755
> --- a/t/t9146-git-svn-empty-dirs.sh
> +++ b/t/t9146-git-svn-empty-dirs.sh
> @@ -82,4 +82,27 @@ test_expect_success 'git svn mkdirs -r works' '
>  	)
>  '
>  
> +test_expect_success 'initialize trunk' '
> +	for i in trunk trunk/a trunk/"weird file name"
> +	do
> +		svn_cmd mkdir -m "mkdir $i" "$svnrepo"/"$i"
> +	done
> +'
> +

Hi Björn,

I'm having a bit of trouble figuring out exactly what you mean
here, can you double check your tests?  Annotations below, thanks

> +test_expect_success 'clone trunk' 'git svn clone -s "$svnrepo" trunk'
                                                    ^^            ^^^^^
                                                           Huh?

> +test_expect_success 'empty directories in trunk exist' '
> +	(
> +		cd cloned &&
                   ^^^^^^ - ?

> +		for i in trunk/a trunk/"weird file name"
> +		do
> +			if ! test -d "$i"
> +			then
> +				echo >&2 "$i does not exist"
> +				exit 1
> +			fi
> +		done

-- 
Eric Wong

^ permalink raw reply

* Re: 'error: unable to set permission to './objects/...'
From: Junio C Hamano @ 2009-11-22 23:27 UTC (permalink / raw)
  To: Rafal Rusin; +Cc: git
In-Reply-To: <9bbf67fa0911221202r605de38coc2496b1f09123725@mail.gmail.com>

Rafal Rusin <rafal.rusin@gmail.com> writes:

> I'm hosting git repository on filesystem with 'chmod <some-file>'
> causing permission denied error (it's smbfs mounted directory),
> When I was doing push to such repo using file:// protocol, I got
> following error:
> error: unable to set permission to './objects/...'
>
> I did a small fix to sha1_file.c (patch in attachment) and git now
> warns when unable to chmod, and continues push. This resolved problem.
> What do you think about applying it?

Suppose the user wanted to use this as a shared public repository and
configured core.sharedrepository.  If we try to set shared-perm and notice
a failure but keep going, what happens to the resulting repository?  

For example, the umask of the user who is pushing objects, causing this
codepath to run, might be too tight to be usable for the purpose of making
the file readable for other members of the group.  And the chmod() fails
in this codepath.  Then what?  Wouldn't it make the resulting repository
unusable?

I think a _fix_ needs to first know why chmod is failing for you and
either

 (1) make it not to fail; or

 (2) Perhaps your filesystem is lying and the result of chmod happens to
     be Ok (iow, the resulting file may be readable/writable by people who
     are supposed to be able to, accoring to the core.sharedrepository
     settings), in which case make the code notice the situation and keep
     going _only when_ it is safe to do so.

I do not think your change to _unconditionally_ keep going is a fix.

^ permalink raw reply

* [PATCH] git svn: always reuse existing remotes on fetch
From: Eric Wong @ 2009-11-22 23:39 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Michael J Gruber, Yaroslav Halchenko
In-Reply-To: <20091120204723.GB30423@dcvr.yhbt.net>

Eric Wong <normalperson@yhbt.net> wrote:
> so there's apparently a bug in our handling of
> svn-remote != "svn" somewhere...

>From 4d0157d6995925ea55ff181ea94d058583333f90 Mon Sep 17 00:00:00 2001
From: Eric Wong <normalperson@yhbt.net>
Date: Sun, 22 Nov 2009 12:37:06 -0800
Subject: [PATCH] git svn: always reuse existing remotes on fetch

The internal no_reuse_existing flag is set to allow initializing
multiple remotes with the same URL, common with SVM users.

Unfortunately, this flag caused misbehavior when used
with the -R command-line flag for fetching.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
 git-svn.perl |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index 2746895..7f7a56f 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -428,6 +428,7 @@ sub cmd_fetch {
 	if (@_ > 1) {
 		die "Usage: $0 fetch [--all] [--parent] [svn-remote]\n";
 	}
+	$Git::SVN::no_reuse_existing = undef;
 	if ($_fetch_parent) {
 		my ($url, $rev, $uuid, $gs) = working_head_info('HEAD');
 		unless ($gs) {
@@ -956,6 +957,7 @@ sub cmd_multi_init {
 }
 
 sub cmd_multi_fetch {
+	$Git::SVN::no_reuse_existing = undef;
 	my $remotes = Git::SVN::read_all_remotes();
 	foreach my $repo_id (sort keys %$remotes) {
 		if ($remotes->{$repo_id}->{url}) {
-- 
Eric Wong

^ permalink raw reply related

* Re: [PATCH] log --format: document %w
From: René Scharfe @ 2009-11-22 23:46 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List
In-Reply-To: <7vzl6eiiyx.fsf@alter.siamese.dyndns.org>

Junio C Hamano schrieb:
> René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:
> 
>> I'm not especially proud of the triple negative in that note.  How to say it
>> better, yet concise?
>> +- '%w([<w>[,<i1>[,<i2>]]])': switch line wrapping, like the -w option of
>> +  linkgit:git-shortlog[1].  NOTE: Color placeholders (`%C*`) are not
>> +  recognized as having no width, so they should not be put into wrapped
>> +  sections.
> 
> "The code miscounts the width of '%C*' color placeholders"?
> 
> Perhaps somebody in the codepath leading to pick_one_utf8_char() in utf8.c
> can be made aware of them?
> 
> utf8_width() is called from many places (has one caller outside utf8.c as
> well).  It is given a pointer to a pointer that points at the current
> position in a string, and is responsible for picking up one logical letter
> advancing the given pointer to skip over that letter, and returning the
> display width of that one letter.  The function wants the string to be
> encoded in utf-8 and signals by putting NULL in the pointer when it
> detects the input string is not.
> 
> Picking up one logical letter is done by pick_one_utf8_char(), which is a
> nicely written generic "We are at the character boundary of a potentially
> multi-byte utf-8 string; pick the first character" implementation, and we
> wouldn't want to contaminate that with escape sequence logic---we might
> want to reuse it in other codepaths where we have no reason to expect any
> escape sequences.
> 
> So perhaps we can introduce is_esc_sequence(s, r, w) that
> 
>  - returns true if we are at the beginning of an esc-sequence;
>  - skips the sequence just like utf8_width() does with s and r; and
>  - counts the width of the sequence and returns it in *w
> 
> The implementation of the is_esc_sequence() could be to only detect the
> color sequence (if the sequence has things like cursor-position control
> then we are already lost, as calling "utf8_width()" on such a string does
> not make much sense anyway) and report zero-width.
> 
> I dunno.
> 
> diff --git a/utf8.c b/utf8.c
> index 5c18f0c..d45e75f 100644
> --- a/utf8.c
> +++ b/utf8.c
> @@ -241,7 +241,12 @@ invalid:
>   */
>  int utf8_width(const char **start, size_t *remainder_p)
>  {
> -	ucs_char_t ch = pick_one_utf8_char(start, remainder_p);
> +	ucs_char_t ch;
> +	int w;
> +
> +	if (is_esc_sequence(start, remainder_p, &w))
> +		return w;
> +	ch = pick_one_utf8_char(start, remainder_p);
>  	if (!*start)
>  		return 0;
>  	return git_wcwidth(ch);

I think utf8_width() is too generic for that; we shouldn't teach it terminal
control details.  Something like this?  It keeps it all local to
strbuf_add_wrapped_text(); ignoring display mode escape codes in there can be
justified with its purpose.

 utf8.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/utf8.c b/utf8.c
index 5c18f0c..fcc0aeb 100644
--- a/utf8.c
+++ b/utf8.c
@@ -298,6 +298,21 @@ static void print_spaces(struct strbuf *buf, int count)
 	strbuf_write(buf, s, count);
 }
 
+/* XXX: this handles display mode sequences, only.  Do we need more? */
+static size_t esc_sequence_len(const char *s)
+{
+	const char *p = s;
+	if (*p++ != '\033')
+		return 0;
+	if (*p++ != '[')
+		return 0;
+	while (isdigit(*p) || *p == ';')
+		p++;
+	if (*p++ != 'm')
+		return 0;
+	return p - s;
+}
+
 /*
  * Wrap the text, if necessary. The variable indent is the indent for the
  * first line, indent2 is the indent for all other lines.
@@ -329,7 +344,13 @@ int strbuf_add_wrapped_text(struct strbuf *buf,
 	}
 
 	for (;;) {
-		char c = *text;
+		char c;
+		size_t skip;
+
+		while ((skip = esc_sequence_len(text)))
+			text += skip;
+
+		c = *text;
 		if (!c || isspace(c)) {
 			if (w < width || !space) {
 				const char *start = bol;

^ permalink raw reply related

* Re: git-svn: Fails to drop leading path from empty dir name
From: Björn Steinbrink @ 2009-11-22 23:52 UTC (permalink / raw)
  To: Eric Wong; +Cc: git
In-Reply-To: <20091122232504.GA28127@dcvr.yhbt.net>

Hi Eric,

On 2009.11.22 15:25:04 -0800, Eric Wong wrote:
> Björn Steinbrink <B.Steinbrink@gmx.de> wrote:

> I'm having a bit of trouble figuring out exactly what you mean
> here, can you double check your tests?  Annotations below, thanks
> 
> > +test_expect_success 'clone trunk' 'git svn clone -s "$svnrepo" trunk'
>                                                     ^^            ^^^^^
>                                                            Huh?
> 
> > +test_expect_success 'empty directories in trunk exist' '
> > +	(
> > +		cd cloned &&
>                    ^^^^^^ - ?
> 
> > +		for i in trunk/a trunk/"weird file name"

Argh, yeah, I messed that patch up, the test only failed because I also
messed up this line, adding the trunk prefix there, too. Fixed patch
below.

SVN Repo layout:

/
|
|---trunk
|   |
... |---foo/ # Empty
    |
    |---bar/
        |
        somefile

with "git svn clone -s svn://host/path/to/repo you get:

.git
bar/
bar/somefile
trunk/foo # This should be just foo/

i.e. the empty directories have their path relative to the repo root,
instead of relative to the directory the git branch is associated with.

Sorry for the messed up first patch.

Björn

diff --git a/t/t9146-git-svn-empty-dirs.sh b/t/t9146-git-svn-empty-dirs.sh
index 5948544..70c52c1 100755
--- a/t/t9146-git-svn-empty-dirs.sh
+++ b/t/t9146-git-svn-empty-dirs.sh
@@ -82,4 +82,27 @@ test_expect_success 'git svn mkdirs -r works' '
 	)
 '
 
+test_expect_success 'initialize trunk' '
+	for i in trunk trunk/a trunk/"weird file name"
+	do
+		svn_cmd mkdir -m "mkdir $i" "$svnrepo"/"$i"
+	done
+'
+
+test_expect_success 'clone trunk' 'git svn clone -s "$svnrepo" trunk'
+
+test_expect_success 'empty directories in trunk exist' '
+	(
+		cd trunk &&
+		for i in a "weird file name"
+		do
+			if ! test -d "$i"
+			then
+				echo >&2 "$i does not exist"
+				exit 1
+			fi
+		done
+	)
+'
+
 test_done

^ permalink raw reply related

* Re: [PATCH] send-email: new 'add-envelope' option
From: Junio C Hamano @ 2009-11-22 23:54 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: Jeff King, git
In-Reply-To: <94a0d4530911220437l5386b36ds4ef06dc66cc11bcc@mail.gmail.com>

Felipe Contreras <felipe.contreras@gmail.com> writes:

> I thought a bit more about this, and in the end what we really want is
> to add the sender envelope. The most typical case would be to use the
> 'from' address, but we should be able to override it (we do both by
> using --envelope-sender).
>
> So here are other options.
>
> a) --add-envelope: add the sender envelope, by default it would be the
> 'from' address, but could be overridden by --envelope-sender.

I do not think the latter half of this description makes much sense, as
the existing --envelope-sender=<this-address> alone already says "add this
envelope sender".

It is unfortunate that we cannot sanely have an option that takes an
optional string argument from the command line.  Ideally, if we can
specify --envelope-sender without any argument, we could make it to mean
"pretend as if the 'from' address is given to this option", but that would
make the command line pasing ambiguous, so we would need an extra option
like this one.  "--envelope-sender=from" might be a more intuitive way to
say this, though.

> b) --envelope-sender="" or "auto": this would require minimal changes
> but looks a bita strange.

An explicit empty string does look very strange, but I do not think a
magic word like "auto" (or "from") that cannot sanely be your envelope
sender address is a bad idea.

> Any thoughts?

It is much easier to work on the configuration front, by the way, and I
expect people who regularly interact with multiple projects to appreciate
this feature would configure their send-email once and forget about it, so
the command line clunkiness might not be such a big issue.

A user who works with more than one projects with different identity known
to each project would use $HOME/.gitconfig and send-email configuration
identity feature to set "sendemail.<identity>.from" and friends in there,
while setting sendemail.identity configuration in .git/config for each
project, so being able to say "use whatever 'from' as the envelope sender"
once in $HOME/.gitconfig would be convenient.

So I could have in $HOME/.gitconfig:

        [sendemail]
		; used as a boolean to say "use from"
                envelopesender
        [sendemail.git]
                from = Junio C Hamano <gitster@pobox.com>
                to = git mailing list <git@vger.kernel.org>
        [sendemail.frotz]
                from = Junio C Hamano <frotzster@example.xz>
                to = frotz mailing list <frotz@example.xz>

and then in my {git,frotz}.git/.git/config would have

        [sendemail]                     [sendemail]
                identity = git                  identity = frotz

respectively.  Without your patch, in $HOME/.gitconfig, I wouldn't have
the global sendemail.envelopesender but have separate individual
configuration variables sendemail.{git,frotz}.envelopesender defined.

^ permalink raw reply

* Re: [PATCH 2/2] user-manual: Document that "git merge" doesn't like uncommited changes.
From: Junio C Hamano @ 2009-11-22 23:57 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Junio C Hamano, git
In-Reply-To: <vpqljhyi4oi.fsf@bauges.imag.fr>

Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:

> Junio C Hamano <gitster@pobox.com> writes:
>
>> "but not the working tree itself" is not incorrect per-se, but misses the
>> point.  How about...
>>
>> 	A merge is made by combining the changes made in "branchname" and
>>         the changes made up to the latest commit in your current branch
>>         since their histories forke.  The work tree is overwritten by the
>>         result of the merge when this combining is done cleanly, or
>>         overwritten by a half-merged results when this combining results
>>         in conflicts.  Therefore, ...
>
> Maybe better. OTOH, it reveals another problem: Your "the work tree is
> overwritten by ..." tend to imply that the result is not commited,
> while the normal case is indeed to create a merge commit
> automatically.

Fair enough.  How about changing this part

>>         since their histories forke.  The work tree is overwritten by the
>>         result of the merge when this combining is done cleanly, or
>>         overwritten by a half-merged results when this combining results

to

	The work tree is overwritten by the result of the
        merge when this combining is done cleanly, and the result is
        committed. Otherwise it is
	overwritten by a half-merged results when this combining results

?        

^ permalink raw reply

* Re: [PATCH] log --format: document %w
From: Junio C Hamano @ 2009-11-23  0:06 UTC (permalink / raw)
  To: René Scharfe; +Cc: Git Mailing List
In-Reply-To: <4B09CD5A.4070401@lsrfire.ath.cx>

René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:

> I think utf8_width() is too generic for that; we shouldn't teach it terminal
> control details.

I agree that the function whose purpose is to compute display width should
not be called utf8_width().

The outside caller of utf8_width() in diff.c uses it to truncate the
function name hint on the hunk header line at character boundary.  The
input shouldn't have color escapes _we_ add (it might contain such
sequences from the user data, though), so I agree that we shouldn't
contaminate this function with color escapes.

> strbuf_add_wrapped_text(); ignoring display mode escape codes in there can be
> justified with its purpose.

Surely, and thanks.  The patch looks good.

^ permalink raw reply

* Re: [PATCH 2/2 v2] user-manual: Document that "git merge" doesn't like uncommited changes.
From: Junio C Hamano @ 2009-11-23  0:08 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git
In-Reply-To: <1258928778-32419-2-git-send-email-Matthieu.Moy@imag.fr>

Looks much nicer; thanks.

Will queue.

^ permalink raw reply

* Re: [PATCH RESEND] Explicitly truncate bswap operand to uint32_t
From: Junio C Hamano @ 2009-11-23  0:16 UTC (permalink / raw)
  To: Benjamin Kramer; +Cc: git, Nicolas Pitre
In-Reply-To: <4B03FC57.5000506@googlemail.com>

Benjamin Kramer <benny.kra@googlemail.com> writes:

> There are some places in git where a long is passed to htonl/ntohl. llvm
> doesn't support matching operands of different bitwidths intentionally.
> This patch fixes the build with llvm-gcc (and clang) on x86_64.
>
> Signed-off-by: Benjamin Kramer <benny.kra@googlemail.com>
> ---
> Any comments on this patch?

My vague recollection is that the response was "we do not mind it per-se,
unless it ends up in an ugly change; but we would prefer if you go fix
your compiler", but maybe I read it on lkml not here?

Also my vague recollection is that the kernel folks took that patch in the
end, so I think it is Ok for us to take this patch, too.

^ permalink raw reply

* [PATCH 1/2] cvsserver doc: database generally can not be reproduced consistently
From: Matthew Ogilvie @ 2009-11-23  2:07 UTC (permalink / raw)
  To: git, gitster; +Cc: Matthew Ogilvie
In-Reply-To: <1258942050-11423-1-git-send-email-mmogilvi_git@miniinfo.net>

A regenerated git-cvsserver database is at risk of having different
CVS revision numbers from an incrementally updated database.  Mention
this in the the documentation, and remove an erroneous statement
to the contrary.

Signed-off-by: Matthew Ogilvie <mmogilvi_git@miniinfo.net>
---
 Documentation/git-cvsserver.txt |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/Documentation/git-cvsserver.txt b/Documentation/git-cvsserver.txt
index 785779e..99a7c14 100644
--- a/Documentation/git-cvsserver.txt
+++ b/Documentation/git-cvsserver.txt
@@ -182,10 +182,9 @@ Database Backend
 ----------------
 
 'git-cvsserver' uses one database per git head (i.e. CVS module) to
-store information about the repository for faster access. The
-database doesn't contain any persistent data and can be completely
-regenerated from the git repository at any time. The database
-needs to be updated (i.e. written to) after every commit.
+store information about the repository to maintain consistent
+CVS revision numbers. The database needs to be
+updated (i.e. written to) after every commit.
 
 If the commit is done directly by using `git` (as opposed to
 using 'git-cvsserver') the update will need to happen on the
@@ -204,6 +203,18 @@ write so it might not be enough to grant the users using
 'git-cvsserver' write access to the database file without granting
 them write access to the directory, too.
 
+The database can not be reliably regenerated in a
+consistent form after the branch it is tracking has changed.
+Example: For merged branches, 'git-cvsserver' only tracks
+one branch of development, and after a 'git-merge' an
+incrementally updated database may track a different branch
+than a database regenerated from scratch, causing inconsistent
+CVS revision numbers. `git-cvsserver` has no way of knowing which
+branch it would have picked if it had been run incrementally
+pre-merge. So if you have to fully or partially (from old
+backup) regenerate the database, you should be suspicious
+of pre-existing CVS sandboxes.
+
 You can configure the database backend with the following
 configuration variables:
 
-- 
1.6.4.GIT

^ 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