* [PATCH v2 3/4] Documentation: format full commands in typewriter font
From: Thomas Rast @ 2010-01-10 0:02 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Jonathan Nieder
In-Reply-To: <cover.1263081032.git.trast@student.ethz.ch>
Use `code snippet` style instead of 'emphasis' for `git cmd ...`
according to the following rules:
* The SYNOPSIS sections are left untouched.
* If the intent is that the user type the command exactly as given, it
is `code`.
If the user is only loosely referred to a command and/or option, it
remains 'emphasised'.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
Documentation/config.txt | 12 ++++++------
Documentation/git-add.txt | 2 +-
Documentation/git-bisect.txt | 2 +-
Documentation/git-cvsserver.txt | 2 +-
Documentation/git-filter-branch.txt | 6 +++---
Documentation/git-ls-tree.txt | 4 ++--
Documentation/git-merge.txt | 14 +++++++-------
Documentation/git-replace.txt | 2 +-
Documentation/git-revert.txt | 4 ++--
Documentation/git-stash.txt | 2 +-
Documentation/git-submodule.txt | 4 ++--
Documentation/git-var.txt | 2 +-
12 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 23a965e..6bfd9e1 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -741,15 +741,15 @@ diff.mnemonicprefix::
standard "a/" and "b/" depending on what is being compared. When
this configuration is in effect, reverse diff output also swaps
the order of the prefixes:
-'git-diff';;
+`git diff`;;
compares the (i)ndex and the (w)ork tree;
-'git-diff HEAD';;
+`git diff HEAD`;;
compares a (c)ommit and the (w)ork tree;
-'git diff --cached';;
+`git diff --cached`;;
compares a (c)ommit and the (i)ndex;
-'git-diff HEAD:file1 file2';;
+`git-diff HEAD:file1 file2`;;
compares an (o)bject and a (w)ork tree entity;
-'git diff --no-index a b';;
+`git diff --no-index a b`;;
compares two non-git things (1) and (2).
diff.renameLimit::
@@ -1015,7 +1015,7 @@ gui.spellingdictionary::
off.
gui.fastcopyblame::
- If true, 'git gui blame' uses '-C' instead of '-C -C' for original
+ If true, 'git gui blame' uses `-C` instead of `-C -C` for original
location detection. It makes blame significantly faster on huge
repositories at the expense of less thorough copy detection.
diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
index 1f1b199..f74fcf3 100644
--- a/Documentation/git-add.txt
+++ b/Documentation/git-add.txt
@@ -39,7 +39,7 @@ The `git add` command will not add ignored files by default. If any
ignored files were explicitly specified on the command line, `git add`
will fail with a list of ignored files. Ignored files reached by
directory recursion or filename globbing performed by Git (quote your
-globs before the shell) will be silently ignored. The `add` command can
+globs before the shell) will be silently ignored. The 'git add' command can
be used to add ignored files with the `-f` (force) option.
Please see linkgit:git-commit[1] for alternative ways to add content to a
diff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt
index c39d957..f91c7ac 100644
--- a/Documentation/git-bisect.txt
+++ b/Documentation/git-bisect.txt
@@ -26,7 +26,7 @@ on the subcommand:
git bisect log
git bisect run <cmd>...
-This command uses 'git rev-list --bisect' to help drive the
+This command uses `git rev-list --bisect` to help drive the
binary search process to find which change introduced a bug, given an
old "good" commit object name and a later "bad" commit object name.
diff --git a/Documentation/git-cvsserver.txt b/Documentation/git-cvsserver.txt
index 99a7c14..19b1daf 100644
--- a/Documentation/git-cvsserver.txt
+++ b/Documentation/git-cvsserver.txt
@@ -294,7 +294,7 @@ To get a checkout with the Eclipse CVS client:
Protocol notes: If you are using anonymous access via pserver, just select that.
Those using SSH access should choose the 'ext' protocol, and configure 'ext'
access on the Preferences->Team->CVS->ExtConnection pane. Set CVS_SERVER to
-"'git cvsserver'". Note that password support is not good when using 'ext',
+"`git cvsserver`". Note that password support is not good when using 'ext',
you will definitely want to have SSH keys setup.
Alternatively, you can just use the non-standard extssh protocol that Eclipse
diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt
index 394a77a..544836a 100644
--- a/Documentation/git-filter-branch.txt
+++ b/Documentation/git-filter-branch.txt
@@ -129,8 +129,8 @@ convenience functions, too. For example, calling 'skip_commit "$@"'
will leave out the current commit (but not its changes! If you want
that, use 'git-rebase' instead).
+
-You can also use the 'git_commit_non_empty_tree "$@"' instead of
-'git commit-tree "$@"' if you don't wish to keep commits with a single parent
+You can also use the `git_commit_non_empty_tree "$@"` instead of
+`git commit-tree "$@"` if you don't wish to keep commits with a single parent
and that makes no change to the tree.
--tag-name-filter <command>::
@@ -179,7 +179,7 @@ the nearest ancestor that was not excluded.
and only one parent, it will hence keep merges points. Also, this
option is not compatible with the use of '--commit-filter'. Though you
just need to use the function 'git_commit_non_empty_tree "$@"' instead
- of the 'git commit-tree "$@"' idiom in your commit filter to make that
+ of the `git commit-tree "$@"` idiom in your commit filter to make that
happen.
--original <namespace>::
diff --git a/Documentation/git-ls-tree.txt b/Documentation/git-ls-tree.txt
index c3fdccb..1f89d36 100644
--- a/Documentation/git-ls-tree.txt
+++ b/Documentation/git-ls-tree.txt
@@ -28,7 +28,7 @@ in the current working directory. Note that:
in a directory 'sub' that has a directory 'dir', you can run 'git
ls-tree -r HEAD dir' to list the contents of the tree (that is
'sub/dir' in 'HEAD'). You don't want to give a tree that is not at the
- root level (e.g. 'git ls-tree -r HEAD:sub dir') in this case, as that
+ root level (e.g. `git ls-tree -r HEAD:sub dir`) in this case, as that
would result in asking for 'sub/sub/dir' in the 'HEAD' commit.
However, the current working directory can be ignored by passing
--full-tree option.
@@ -84,7 +84,7 @@ Output Format
Unless the `-z` option is used, TAB, LF, and backslash characters
in pathnames are represented as `\t`, `\n`, and `\\`, respectively.
-This output format is compatible with what '--index-info --stdin' of
+This output format is compatible with what `--index-info --stdin` of
'git update-index' expects.
When the `-l` option is used, format changes to
diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt
index 3277f4e..04c21d3 100644
--- a/Documentation/git-merge.txt
+++ b/Documentation/git-merge.txt
@@ -193,7 +193,7 @@ After seeing a conflict, you can do two things:
* Decide not to merge. The only clean-ups you need are to reset
the index file to the `HEAD` commit to reverse 2. and to clean
- up working tree changes made by 2. and 3.; 'git-reset --hard' can
+ up working tree changes made by 2. and 3.; `git-reset --hard` can
be used for this.
* Resolve the conflicts. Git will mark the conflicts in
@@ -202,19 +202,19 @@ After seeing a conflict, you can do two things:
You can work through the conflict with a number of tools:
- * Use a mergetool. 'git mergetool' to launch a graphical
+ * Use a mergetool. `git mergetool` to launch a graphical
mergetool which will work you through the merge.
- * Look at the diffs. 'git diff' will show a three-way diff,
+ * Look at the diffs. `git diff` will show a three-way diff,
highlighting changes from both the HEAD and their versions.
- * Look at the diffs on their own. 'git log --merge -p <path>'
+ * Look at the diffs on their own. `git log --merge -p <path>`
will show diffs first for the HEAD version and then
their version.
- * Look at the originals. 'git show :1:filename' shows the
- common ancestor, 'git show :2:filename' shows the HEAD
- version and 'git show :3:filename' shows their version.
+ * Look at the originals. `git show :1:filename` shows the
+ common ancestor, `git show :2:filename` shows the HEAD
+ version and `git show :3:filename` shows their version.
EXAMPLES
diff --git a/Documentation/git-replace.txt b/Documentation/git-replace.txt
index 65a0da5..fde2092 100644
--- a/Documentation/git-replace.txt
+++ b/Documentation/git-replace.txt
@@ -65,7 +65,7 @@ OPTIONS
BUGS
----
Comparing blobs or trees that have been replaced with those that
-replace them will not work properly. And using 'git reset --hard' to
+replace them will not work properly. And using `git reset --hard` to
go back to a replaced commit will move the branch to the replacement
commit instead of the replaced commit.
diff --git a/Documentation/git-revert.txt b/Documentation/git-revert.txt
index 5e11758..36f3bc3 100644
--- a/Documentation/git-revert.txt
+++ b/Documentation/git-revert.txt
@@ -20,8 +20,8 @@ effect of an earlier commit (often a faulty one). If you want to
throw away all uncommitted changes in your working directory, you
should see linkgit:git-reset[1], particularly the '--hard' option. If
you want to extract specific files as they were in another commit, you
-should see linkgit:git-checkout[1], specifically the 'git checkout
-<commit> -- <filename>' syntax. Take care with these alternatives as
+should see linkgit:git-checkout[1], specifically the `git checkout
+<commit> -- <filename>` syntax. Take care with these alternatives as
both will discard uncommitted changes in your working directory.
OPTIONS
diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt
index 3f14b72..f001d0e 100644
--- a/Documentation/git-stash.txt
+++ b/Documentation/git-stash.txt
@@ -20,7 +20,7 @@ SYNOPSIS
DESCRIPTION
-----------
-Use 'git stash' when you want to record the current state of the
+Use `git stash` when you want to record the current state of the
working directory and the index, but want to go back to a clean
working directory. The command saves your local modifications away
and reverts the working directory to match the `HEAD` commit.
diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
index 4ef70c4..68f656c 100644
--- a/Documentation/git-submodule.txt
+++ b/Documentation/git-submodule.txt
@@ -114,8 +114,8 @@ init::
The key used in .git/config is `submodule.$name.url`.
This command does not alter existing information in .git/config.
You can then customize the submodule clone URLs in .git/config
- for your local setup and proceed to 'git submodule update';
- you can also just use 'git submodule update --init' without
+ for your local setup and proceed to `git submodule update`;
+ you can also just use `git submodule update --init` without
the explicit 'init' step if you do not intend to customize
any submodule locations.
diff --git a/Documentation/git-var.txt b/Documentation/git-var.txt
index ef6aa81..bb98182 100644
--- a/Documentation/git-var.txt
+++ b/Documentation/git-var.txt
@@ -20,7 +20,7 @@ OPTIONS
Cause the logical variables to be listed. In addition, all the
variables of the git configuration file .git/config are listed
as well. (However, the configuration variables listing functionality
- is deprecated in favor of 'git config -l'.)
+ is deprecated in favor of `git config -l`.)
EXAMPLE
--------
--
1.6.6.218.g502b0
^ permalink raw reply related
* [PATCH v2 2/4] Documentation: warn prominently against merging with dirty trees
From: Thomas Rast @ 2010-01-10 0:02 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Jonathan Nieder
In-Reply-To: <cover.1263081032.git.trast@student.ethz.ch>
We do this for both git-merge and git-pull, so as to hopefully alert
(over)users of git-pull to the issue.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
Documentation/git-merge.txt | 4 ++++
Documentation/git-pull.txt | 4 ++++
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt
index 4896587..3277f4e 100644
--- a/Documentation/git-merge.txt
+++ b/Documentation/git-merge.txt
@@ -22,6 +22,10 @@ The second syntax (<msg> `HEAD` <commit>...) is supported for
historical reasons. Do not use it from the command line or in
new scripts. It is the same as `git merge -m <msg> <commit>...`.
+*Warning*: Running 'git-merge' with uncommitted changes is
+discouraged: while possible, it leaves you in a state that is hard to
+back out of in the case of a conflict.
+
OPTIONS
-------
diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt
index b932011..b3fa312 100644
--- a/Documentation/git-pull.txt
+++ b/Documentation/git-pull.txt
@@ -24,6 +24,10 @@ when merging local branches into the current branch.
Also note that options meant for 'git-pull' itself and underlying
'git-merge' must be given before the options meant for 'git-fetch'.
+*Warning*: Running 'git-pull' (actually, the underlying 'git-merge')
+with uncommitted changes is discouraged: while possible, it leaves you
+in a state that is hard to back out of in the case of a conflict.
+
OPTIONS
-------
--
1.6.6.218.g502b0
^ permalink raw reply related
* [PATCH v2 1/4] Documentation/git-merge: reword references to "remote" and "pull"
From: Thomas Rast @ 2010-01-10 0:02 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Jonathan Nieder
In-Reply-To: <cover.1263081032.git.trast@student.ethz.ch>
The git-merge manpage was written in terms of merging a "remote",
which is no longer the case: you merge local or remote-tracking
branches; pull is for actual remotes.
Adjust the manpage accordingly. We refer to the arguments as
"commits", and change instances of "remote" to "other" (where branches
are concerned) or "theirs" (where conflict sides are concerned).
Remove the single reference to "pulling".
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
Documentation/git-merge.txt | 34 +++++++++++++++++-----------------
1 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt
index e886c2e..4896587 100644
--- a/Documentation/git-merge.txt
+++ b/Documentation/git-merge.txt
@@ -10,17 +10,17 @@ SYNOPSIS
--------
[verse]
'git merge' [-n] [--stat] [--no-commit] [--squash] [-s <strategy>]...
- [-m <msg>] <remote>...
-'git merge' <msg> HEAD <remote>...
+ [-m <msg>] <commit>...
+'git merge' <msg> HEAD <commit>...
DESCRIPTION
-----------
-This is the top-level interface to the merge machinery
-which drives multiple merge strategy scripts.
+Merges the history specified by <commit> into HEAD, optionally using a
+specific merge strategy.
-The second syntax (<msg> `HEAD` <remote>) is supported for
+The second syntax (<msg> `HEAD` <commit>...) is supported for
historical reasons. Do not use it from the command line or in
-new scripts. It is the same as `git merge -m <msg> <remote>`.
+new scripts. It is the same as `git merge -m <msg> <commit>...`.
OPTIONS
@@ -33,10 +33,10 @@ include::merge-options.txt[]
used to give a good default for automated 'git merge'
invocations.
-<remote>...::
- Other branch heads to merge into our branch. You need at
- least one <remote>. Specifying more than one <remote>
- obviously means you are trying an Octopus.
+<commit>...::
+ Commits, usually other branch heads, to merge into our branch.
+ You need at least one <commit>. Specifying more than one
+ <commit> obviously means you are trying an Octopus.
include::merge-strategies.txt[]
@@ -96,8 +96,8 @@ file matches exactly the current `HEAD` commit; otherwise we
will write out your local changes already registered in your
index file along with the merge result, which is not good.
Because 1. involves only those paths differing between your
-branch and the remote branch you are pulling from during the
-merge (which is typically a fraction of the whole tree), you can
+branch and the branch you are merging
+(which is typically a fraction of the whole tree), you can
have local modifications in your working tree as long as they do
not overlap with what the merge updates.
@@ -110,7 +110,7 @@ When there are conflicts, the following happens:
3. For conflicting paths, the index file records up to three
versions; stage1 stores the version from the common ancestor,
- stage2 from `HEAD`, and stage3 from the remote branch (you
+ stage2 from `HEAD`, and stage3 from the other branch (you
can inspect the stages with `git ls-files -u`). The working
tree files contain the result of the "merge" program; i.e. 3-way
merge results with familiar conflict markers `<<< === >>>`.
@@ -202,15 +202,15 @@ You can work through the conflict with a number of tools:
mergetool which will work you through the merge.
* Look at the diffs. 'git diff' will show a three-way diff,
- highlighting changes from both the HEAD and remote versions.
+ highlighting changes from both the HEAD and their versions.
* Look at the diffs on their own. 'git log --merge -p <path>'
- will show diffs first for the HEAD version and then the
- remote version.
+ will show diffs first for the HEAD version and then
+ their version.
* Look at the originals. 'git show :1:filename' shows the
common ancestor, 'git show :2:filename' shows the HEAD
- version and 'git show :3:filename' shows the remote version.
+ version and 'git show :3:filename' shows their version.
EXAMPLES
--
1.6.6.218.g502b0
^ permalink raw reply related
* [PATCH v2 0/4] Documentation style fixes
From: Thomas Rast @ 2010-01-10 0:02 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Jonathan Nieder
In-Reply-To: <7vaawp4wvz.fsf@alter.siamese.dyndns.org>
I'm violating the midnight rule, so there's probably something wrong
with this series.
Junio C Hamano wrote:
> I am tempted to suggest describing the command in terms of more common use
> pattern, describing the flexible and more general form as "an aside" for
> more advanced users, perhaps like this.
>
> <branch>...:
> Other branch to merge into the current branch...trying an
> Octopus merge.
> +
> Strictly speaking, these can name arbitrary commits, not necessarily
> at the tip of branches. e.g. "git merge topic{tilde}4" lets you merge
> the topic except for the last 4 commits.
>
> I don't know if such an arrangement really makes the document more
> approachable to new people, or it is making the description longer and
> more complicated without helping new people, though (that is why this is
> just "I am tempted to").
Not sure. I have a bit of an aversion against "lying" in the
synopsis, even though the common use-case really is a branch.
> Thomas Rast <trast@student.ethz.ch> writes:
> > * More importantly, while `code` style seems to be an improvement in
> > HTML output (because it gives typewriter font), my local 'man'
> > renders 'emphasis' as underlines -- which actually makes the code
> > snippets much more visible than `literal` quotes which are not
> > rendered specially at all.
> >
> > So which way should it be changed?
>
> I'd prefer to see us mark code as `code`.
I tried to make it so, including a few other places that grep found.
Regarding 'git-cmd' vs. 'git cmd', I found that we're in the somewhat
unsatisfactory situation where the git-svn manpage uses dashless since
647ac70 (git-svn.txt: stop using dash-form of commands., 2009-07-07).
Most of the rest uses dashed, but there sometimes even were
inconsistent uses very close to each other. Dashless seems to be a
bit more common in newer patches, and does have the advantage that it
does not need an exception for 'git submodule update' and friends.
So I tried to sed it towards the dashless form, with a few exceptions.
The churn, of course, is rather daunting. The other alternative,
returning to dashed forms, would mean reverting 647ac70 and then more
applications of sed to fix the stray dashless uses, being careful to
preserve the SYNOPSIS sections.
Thomas Rast (4):
Documentation/git-merge: reword references to "remote" and "pull"
Documentation: warn prominently against merging with dirty trees
Documentation: format full commands in typewriter font
Documentation: spell 'git cmd' without dash throughout
Documentation/config.txt | 70 +++++++-------
Documentation/fetch-options.txt | 10 +-
Documentation/git-add.txt | 2 +-
Documentation/git-am.txt | 10 +-
Documentation/git-apply.txt | 10 +-
Documentation/git-archimport.txt | 12 ++--
Documentation/git-archive.txt | 2 +-
Documentation/git-bisect.txt | 2 +-
Documentation/git-blame.txt | 8 +-
Documentation/git-branch.txt | 6 +-
Documentation/git-bundle.txt | 26 +++---
Documentation/git-check-ref-format.txt | 2 +-
Documentation/git-checkout-index.txt | 8 +-
Documentation/git-cherry-pick.txt | 2 +-
Documentation/git-cherry.txt | 6 +-
Documentation/git-citool.txt | 4 +-
Documentation/git-clean.txt | 4 +-
Documentation/git-commit-tree.txt | 2 +-
Documentation/git-commit.txt | 18 ++--
Documentation/git-config.txt | 14 ++--
Documentation/git-cvsexportcommit.txt | 2 +-
Documentation/git-cvsimport.txt | 18 ++--
Documentation/git-cvsserver.txt | 6 +-
Documentation/git-daemon.txt | 40 ++++----
Documentation/git-describe.txt | 6 +-
Documentation/git-diff-files.txt | 2 +-
Documentation/git-diff-index.txt | 16 ++--
Documentation/git-diff-tree.txt | 4 +-
Documentation/git-difftool.txt | 16 ++--
Documentation/git-fast-export.txt | 12 ++--
Documentation/git-fast-import.txt | 20 ++--
Documentation/git-fetch-pack.txt | 6 +-
Documentation/git-fetch.txt | 2 +-
Documentation/git-filter-branch.txt | 24 +++---
Documentation/git-fmt-merge-msg.txt | 2 +-
Documentation/git-format-patch.txt | 4 +-
Documentation/git-fsck.txt | 4 +-
Documentation/git-gc.txt | 18 ++--
Documentation/git-get-tar-commit-id.txt | 4 +-
Documentation/git-grep.txt | 2 +-
Documentation/git-gui.txt | 20 ++--
Documentation/git-hash-object.txt | 2 +-
Documentation/git-help.txt | 6 +-
Documentation/git-http-backend.txt | 22 +++---
Documentation/git-http-fetch.txt | 2 +-
Documentation/git-imap-send.txt | 2 +-
Documentation/git-index-pack.txt | 8 +-
Documentation/git-init.txt | 6 +-
Documentation/git-log.txt | 2 +-
Documentation/git-ls-files.txt | 4 +-
Documentation/git-ls-tree.txt | 4 +-
Documentation/git-mailinfo.txt | 2 +-
Documentation/git-merge-file.txt | 10 +-
Documentation/git-merge-index.txt | 6 +-
Documentation/git-merge-one-file.txt | 2 +-
Documentation/git-merge.txt | 54 ++++++-----
Documentation/git-mergetool.txt | 16 ++--
Documentation/git-name-rev.txt | 4 +-
Documentation/git-notes.txt | 2 +-
Documentation/git-pack-objects.txt | 6 +-
Documentation/git-pack-redundant.txt | 2 +-
Documentation/git-patch-id.txt | 2 +-
Documentation/git-peek-remote.txt | 2 +-
Documentation/git-prune.txt | 14 ++--
Documentation/git-pull.txt | 14 ++-
Documentation/git-push.txt | 6 +-
Documentation/git-read-tree.txt | 40 ++++----
Documentation/git-rebase.txt | 38 ++++----
Documentation/git-receive-pack.txt | 6 +-
Documentation/git-reflog.txt | 2 +-
Documentation/git-remote.txt | 2 +-
Documentation/git-repack.txt | 10 +-
Documentation/git-replace.txt | 2 +-
Documentation/git-rerere.txt | 26 +++---
Documentation/git-reset.txt | 2 +-
Documentation/git-rev-list.txt | 6 +-
Documentation/git-rev-parse.txt | 30 +++---
Documentation/git-revert.txt | 8 +-
Documentation/git-send-pack.txt | 4 +-
Documentation/git-sh-setup.txt | 2 +-
Documentation/git-shortlog.txt | 4 +-
Documentation/git-show-index.txt | 2 +-
Documentation/git-show-ref.txt | 4 +-
Documentation/git-show.txt | 4 +-
Documentation/git-stash.txt | 8 +-
Documentation/git-status.txt | 2 +-
Documentation/git-submodule.txt | 8 +-
Documentation/git-symbolic-ref.txt | 2 +-
Documentation/git-tag.txt | 6 +-
Documentation/git-tar-tree.txt | 4 +-
Documentation/git-update-index.txt | 14 ++--
Documentation/git-upload-archive.txt | 2 +-
Documentation/git-upload-pack.txt | 8 +-
Documentation/git-var.txt | 2 +-
Documentation/git-verify-pack.txt | 2 +-
Documentation/git-verify-tag.txt | 2 +-
Documentation/git-web--browse.txt | 2 +-
Documentation/git-whatchanged.txt | 4 +-
Documentation/git-write-tree.txt | 8 +-
Documentation/git.txt | 8 +-
Documentation/gitattributes.txt | 12 ++--
Documentation/gitcore-tutorial.txt | 148 +++++++++++++++---------------
Documentation/gitcvs-migration.txt | 10 +-
Documentation/gitdiffcore.txt | 8 +-
Documentation/githooks.txt | 56 ++++++------
Documentation/gitignore.txt | 4 +-
Documentation/gitk.txt | 2 +-
Documentation/gitrepository-layout.txt | 16 ++--
Documentation/gittutorial-2.txt | 16 ++--
Documentation/gittutorial.txt | 42 +++++-----
Documentation/gitworkflows.txt | 6 +-
Documentation/i18n.txt | 4 +-
Documentation/merge-options.txt | 4 +-
Documentation/pull-fetch-param.txt | 8 +-
Documentation/urls-remotes.txt | 4 +-
115 files changed, 634 insertions(+), 626 deletions(-)
^ permalink raw reply
* [PATCH resend] gitk: Adjust two equal strings which differed in whitespace
From: Markus Heidelberg @ 2010-01-09 22:11 UTC (permalink / raw)
To: Paul Mackerras, Christian Stimming; +Cc: git, Markus Heidelberg
There were the two strings "SHA1 ID: " and "SHA1 ID:" as description for
the SHA1 search textbox. Change it to two equal strings, the space is
now outside of the translated string.
Furthermore the German translation wasn't unique, but "SHA1:" resp.
"SHA1-Hashwert:". The former was displayed after initialisation, the
latter after changes to the textbox, for example when clearing the text.
But it was too long to be displayed fully, so use a shorter translation.
Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de>
---
gitk | 2 +-
po/de.po | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/gitk b/gitk
index 86dff0f..d8364c4 100755
--- a/gitk
+++ b/gitk
@@ -2088,7 +2088,7 @@ proc makewindow {} {
set sha1entry .tf.bar.sha1
set entries $sha1entry
set sha1but .tf.bar.sha1label
- button $sha1but -text [mc "SHA1 ID: "] -state disabled -relief flat \
+ button $sha1but -text "[mc "SHA1 ID:"] " -state disabled -relief flat \
-command gotocommit -width 8
$sha1but conf -disabledforeground [$sha1but cget -foreground]
pack .tf.bar.sha1label -side left
diff --git a/po/de.po b/po/de.po
index 53ef0d6..e224595 100644
--- a/po/de.po
+++ b/po/de.po
@@ -708,7 +708,7 @@ msgstr "Gehe zu:"
#: gitk:7821
msgid "SHA1 ID:"
-msgstr "SHA1-Hashwert:"
+msgstr "SHA1 ID:"
#: gitk:7840
#, tcl-format
--
1.6.6.109.g052a6a
^ permalink raw reply related
* Re: [PATCH (v2) 2/2] rebase -i: teach --onto A...B syntax
From: Avery Pennarun @ 2010-01-09 21:02 UTC (permalink / raw)
To: Johannes Schindelin
Cc: A Large Angry SCM, Sverre Rabbelier, Junio C Hamano,
Nanako Shiraishi, git
In-Reply-To: <alpine.DEB.1.00.1001090235520.4985@pacific.mpi-cbg.de>
On Fri, Jan 8, 2010 at 8:36 PM, Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
> On Fri, 8 Jan 2010, A Large Angry SCM wrote:
>> Sverre Rabbelier wrote:
>> > *cough* git sequencer *cough*
>>
>> *cough* not in my ${PATH} *cough*
>
> *cough* because that GSoC project failed in all but writing? *cough*
Is there a summary of the results somewhere? I can find a lot of
discussions of git-sequencer, but not what went right/wrong or if it
turned out to be a good/bad idea.
Avery
^ permalink raw reply
* Re: For real now: bug tracking and secretary tasks in git
From: Thiago Farina @ 2010-01-09 20:22 UTC (permalink / raw)
To: Jan Krüger; +Cc: Git ML
In-Reply-To: <20100109013850.16f82412@perceptron>
On Fri, Jan 8, 2010 at 10:38 PM, Jan Krüger <jk@jk.gs> wrote:
> The proposal goes like this:
>
> * Set up bug tracker (done; it's at http://gitbugs.jk.gs/).
Thanks for doing that!!
^ permalink raw reply
* Re: [PATCH] ls-files: fix overeager pathspec optimization
From: Linus Torvalds @ 2010-01-09 18:05 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Jeff King, Michael J Gruber, Jon Schewe, spearce, git
In-Reply-To: <7vfx6f3dm3.fsf@alter.siamese.dyndns.org>
On Sat, 9 Jan 2010, Junio C Hamano wrote:
>
> Having sent these patches, I am wondering if the simplest fix might be this
> one-liner.
>
> diff --git a/dir.c b/dir.c
> index d0999ba..7fba335 100644
> --- a/dir.c
> +++ b/dir.c
> @@ -788,3 +788,3 @@ int read_directory(struct dir_struct *dir, const char *path, int len, const char
> simplify = create_simplify(pathspec);
> - read_directory_recursive(dir, path, len, 0, simplify);
> + read_directory_recursive(dir, "", 0, 0, simplify);
> free_simplify(simplify);
That one-liner doesn't work at all for me.
Lookie here:
[torvalds@nehalem linux]$ touch drivers/char/hello.c
[torvalds@nehalem linux]$ ~/git/git ls-files --exclude-standard -o drivers/char
[torvalds@nehalem linux]$ git ls-files --exclude-standard -o drivers/char
drivers/char/hello.c
where that ~/git/git is the version with the one-liner.
IOW, it now ignores _everything_, because the dir and the path don't
match.
Linus
^ permalink raw reply
* [BUGFIX] Reset possible helper before reusing remote structure
From: Ilari Liusvaara @ 2010-01-09 17:28 UTC (permalink / raw)
To: git
If one had multiple URLs configured for remote with previous one
having forced helper but the subsequent one not, like:
url = foo::bar://baz
url = ssh://example/example.git
Then the subsequent URL is passed to foo helper, which isn't
correct. Fix it to be parsed normally by resetting foreign VCS
name before parsing the URL protocol.
Signed-off-by: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
---
transport.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/transport.c b/transport.c
index 97bb5e6..669bc85 100644
--- a/transport.c
+++ b/transport.c
@@ -875,6 +875,9 @@ struct transport *transport_get(struct remote *remote, const char *url)
url = remote->url[0];
ret->url = url;
+ /* In case previous URL had helper forced, reset it. */
+ remote->foreign_vcs = NULL;
+
/* maybe it is a foreign URL? */
if (url) {
const char *p = url;
--
1.6.6.3.gaa2e1
^ permalink raw reply related
* Re: [PATCH v2 0/2] Support relative .git file in a submodule
From: Junio C Hamano @ 2010-01-09 17:20 UTC (permalink / raw)
To: Brad King; +Cc: git, Avery Pennarun, Lars Hjemli
In-Reply-To: <1263008201-27429-1-git-send-email-brad.king@kitware.com>
Brad King <brad.king@kitware.com> writes:
> Exactly. In fact the experiment I was doing involved creating submodule
> repos inside the main .git and linking to them from the work tree
> subdirectories. I'm looking into combining the approach with that of
> git-new-workdir to keep submodules in the same object database.
Nice.
I recall we discussed design ideas to allow moving the submodule worktree
and repository more easily using "gitdir:" when we first discussed the
patch series. I am glad to see finally it is going forward.
^ permalink raw reply
* Re: [PATCH] daemon: consider only address in kill_some_child()
From: Junio C Hamano @ 2010-01-09 17:20 UTC (permalink / raw)
To: Erik Faye-Lund; +Cc: git, Erik Faye-Lund
In-Reply-To: <1263046408-2368-1-git-send-email-kusmabite@gmail.com>
Erik Faye-Lund <kusmabite@googlemail.com> writes:
> kill_some_child() compares the entire sockaddr_storage structure (with
> the pad-bits zeroed out) when trying to find out if connections
> originate from the same host. However, sockaddr_storage contains the
> port-number for the connection (which varies between connections), so
> the comparison always fails.
>
> Change the code so we only consider the host-address, by introducing the
> addrcmp()-function that inspects the address family and compare as
> appropriate.
>
> Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
> ---
Makes sense.
^ permalink raw reply
* [PATCH] daemon: consider only address in kill_some_child()
From: Erik Faye-Lund @ 2010-01-09 14:13 UTC (permalink / raw)
To: git; +Cc: Erik Faye-Lund
kill_some_child() compares the entire sockaddr_storage
structure (with the pad-bits zeroed out) when trying to
find out if connections originate from the same host.
However, sockaddr_storage contains the port-number for
the connection (which varies between connections), so
the comparison always fails.
Change the code so we only consider the host-address,
by introducing the addrcmp()-function that inspects
the address family and compare as appropriate.
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
---
daemon.c | 28 ++++++++++++++++++++--------
1 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/daemon.c b/daemon.c
index 5783e24..918e560 100644
--- a/daemon.c
+++ b/daemon.c
@@ -562,6 +562,24 @@ static int execute(struct sockaddr *addr)
return -1;
}
+static int addrcmp(const struct sockaddr_storage *s1,
+ const struct sockaddr_storage *s2)
+{
+ if (s1->ss_family != s2->ss_family)
+ return s1->ss_family - s2->ss_family;
+ if (s1->ss_family == AF_INET)
+ return memcmp(&((struct sockaddr_in *)s1)->sin_addr,
+ &((struct sockaddr_in *)s2)->sin_addr,
+ sizeof(struct in_addr));
+#ifndef NO_IPV6
+ if (s1->ss_family == AF_INET6)
+ return memcmp(&((struct sockaddr_in6 *)s1)->sin6_addr,
+ &((struct sockaddr_in6 *)s2)->sin6_addr,
+ sizeof(struct in6_addr));
+#endif
+ return 0;
+}
+
static int max_connections = 32;
static unsigned int live_children;
@@ -576,17 +594,12 @@ static void add_child(pid_t pid, struct sockaddr *addr, int addrlen)
{
struct child *newborn, **cradle;
- /*
- * This must be xcalloc() -- we'll compare the whole sockaddr_storage
- * but individual address may be shorter.
- */
newborn = xcalloc(1, sizeof(*newborn));
live_children++;
newborn->pid = pid;
memcpy(&newborn->address, addr, addrlen);
for (cradle = &firstborn; *cradle; cradle = &(*cradle)->next)
- if (!memcmp(&(*cradle)->address, &newborn->address,
- sizeof(newborn->address)))
+ if (!addrcmp(&(*cradle)->address, &newborn->address))
break;
newborn->next = *cradle;
*cradle = newborn;
@@ -619,8 +632,7 @@ static void kill_some_child(void)
return;
for (; (next = blanket->next); blanket = next)
- if (!memcmp(&blanket->address, &next->address,
- sizeof(next->address))) {
+ if (!addrcmp(&blanket->address, &next->address)) {
kill(blanket->pid, SIGTERM);
break;
}
--
1.6.6.95.gae285
^ permalink raw reply related
* [RFC PATCH v2 1/2] Report exec errors from run-command
From: Ilari Liusvaara @ 2010-01-09 13:45 UTC (permalink / raw)
To: git
In-Reply-To: <1263044757-12560-1-git-send-email-ilari.liusvaara@elisanet.fi>
Previously run-command was unable to report errors happening in exec
call. Change it to pass errno from failed exec to errno value at
return. Also add special mode that diffrentiates between ENOENT
from exec and ENOENT from other source.
The errno value passing can be done by opening close-on-exec pipe and
piping the error code through in case of failure. In case of success,
close-on-exec closes the pipe on successful exec and parent process
gets end of file on read.
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
---
Documentation/technical/api-run-command.txt | 2 +
Makefile | 1 +
run-command.c | 196 +++++++++++++++++++++++++--
run-command.h | 2 +
t/t0061-run-command.sh | 20 +++
test-run-command.c | 74 ++++++++++
6 files changed, 282 insertions(+), 13 deletions(-)
create mode 100755 t/t0061-run-command.sh
create mode 100644 test-run-command.c
diff --git a/Documentation/technical/api-run-command.txt b/Documentation/technical/api-run-command.txt
index b26c281..f37d8ba 100644
--- a/Documentation/technical/api-run-command.txt
+++ b/Documentation/technical/api-run-command.txt
@@ -49,6 +49,8 @@ The functions above do the following:
. If the program was not found, then -1 is returned and errno is set to
ENOENT; a diagnostic is printed only if .silent_exec_failure is 0.
+ (if extended_error_code flag is true, instead of -1, the return value
+ is -2 in this case).
. Otherwise, the program is run. If it terminates regularly, its exit
code is returned. No diagnistic is printed, even if the exit code is
diff --git a/Makefile b/Makefile
index a2fce5a..92eed68 100644
--- a/Makefile
+++ b/Makefile
@@ -1753,6 +1753,7 @@ TEST_PROGRAMS_NEED_X += test-path-utils
TEST_PROGRAMS_NEED_X += test-sha1
TEST_PROGRAMS_NEED_X += test-sigchain
TEST_PROGRAMS_NEED_X += test-index-version
+TEST_PROGRAMS_NEED_X += test-run-command
TEST_PROGRAMS = $(patsubst %,%$X,$(TEST_PROGRAMS_NEED_X))
diff --git a/run-command.c b/run-command.c
index 47ced57..b1af9c4 100644
--- a/run-command.c
+++ b/run-command.c
@@ -15,6 +15,20 @@ static inline void dup_devnull(int to)
close(fd);
}
+static inline void force_close(int fd)
+{
+ /*
+ * Assume all errors except EINTR are persistent and
+ * that EBADF signals already closed fd.
+ */
+ while (close(fd) < 0 && errno != EBADF)
+ if (errno != EINTR) {
+ warning("Close returned error %s",
+ strerror(errno));
+ break;
+ }
+}
+
static const char **prepare_shell_cmd(const char **argv)
{
int argc, nargc = 0;
@@ -49,6 +63,8 @@ static const char **prepare_shell_cmd(const char **argv)
}
#ifndef WIN32
+int child_err = -1;
+
static int execv_shell_cmd(const char **argv)
{
const char **nargv = prepare_shell_cmd(argv);
@@ -57,6 +73,26 @@ static int execv_shell_cmd(const char **argv)
free(nargv);
return -1;
}
+
+static void error_child(const char *err, ...)
+{
+ char msg[4096];
+ int len;
+ va_list args;
+ va_start(args, err);
+ len = vsnprintf(msg, sizeof(msg), err, args);
+ va_end(args);
+ if (len >= sizeof(msg))
+ len = sizeof(msg) - 1;
+
+ if (child_err < 0)
+ return;
+
+ write(child_err, "error: ", 7);
+ write(child_err, msg, len);
+ write(child_err, "\n", 1);
+}
+
#endif
int start_command(struct child_process *cmd)
@@ -64,6 +100,7 @@ int start_command(struct child_process *cmd)
int need_in, need_out, need_err;
int fdin[2], fdout[2], fderr[2];
int failed_errno = failed_errno;
+ int func_ret = 0;
/*
* In case of errors we must keep the promise to close FDs
@@ -120,9 +157,91 @@ fail_pipe:
trace_argv_printf(cmd->argv, "trace: run_command:");
#ifndef WIN32
+{
+ int report_pipe[2] = {-1, -1};
+
+ if (pipe(report_pipe) < 0) {
+ report_pipe[0] = -1;
+ report_pipe[1] = -1;
+ warning("Can't open pipe for exec status report: %s\n",
+ strerror(errno));
+ }
+
fflush(NULL);
cmd->pid = fork();
- if (!cmd->pid) {
+ if (cmd->pid > 0) {
+ int r = 0, ret = 0;
+ force_close(report_pipe[1]);
+read_again:
+ if (report_pipe[0] >= 0)
+ r = read(report_pipe[0], &ret, sizeof(ret));
+ if (r < 0 && (errno == EAGAIN || errno == EINTR ||
+ errno == EWOULDBLOCK))
+ goto read_again;
+ else if (r < 0)
+ warning("Can't read exec status report: %s\n",
+ strerror(errno));
+ else if (r == 0)
+ ;
+ else if (r < sizeof(ret)) {
+ warning("Received incomplete exec status report.\n");
+ } else {
+ failed_errno = ret;
+ /*
+ * Clean up the process that did the failed execution
+ * so no zombies remain.
+ */
+ while (waitpid(cmd->pid, &ret, 0) < 0 && errno == EINTR)
+ /* Nothing. */ ;
+ if (WIFEXITED(ret) && WEXITSTATUS(ret) == 127)
+ /* Program was not found. */
+ func_ret = -2;
+ cmd->pid = -1;
+ }
+ } else if (!cmd->pid) {
+ int r = 0;
+ int errored = 0;
+ int flags;
+ force_close(report_pipe[0]);
+
+ flags = fcntl(report_pipe[1], F_GETFD);
+ if (flags < 0)
+ r = -1;
+ r = (r || fcntl(report_pipe[1], F_SETFD, flags | FD_CLOEXEC));
+ if (r) {
+ warning("Can't FD_CLOEXEC pipe for exec status report: %s",
+ strerror(errno));
+ force_close(report_pipe[1]);
+ report_pipe[1] = -1;
+ }
+
+ /*
+ * Redirect the channel to write syscall error messages to
+ * before redirecting the process's stderr so that all error
+ * messages in subsequent call paths use the parent's stderr.
+ */
+ if (cmd->no_stderr || need_err) {
+ child_err = dup(2);
+ if (child_err < 0 && errno != EBADF)
+ /* EBADF => No stderr, nowhere to go. */
+ warning("Can't dup fd for child exec errors: %s",
+ strerror(errno));
+ if (child_err < 0)
+ goto no_error_chan;
+
+ flags = fcntl(child_err, F_GETFL);
+ if (flags < 0)
+ flags = 0;
+ if (fcntl(child_err, F_SETFL, flags | FD_CLOEXEC) < 0) {
+ warning("Can't FD_CLOEXEC fd for child exec errors: %s",
+ strerror(errno));
+ force_close(report_pipe[1]);
+ child_err = -1;
+ }
+ } else
+ child_err = 2;
+no_error_chan:
+
if (cmd->no_stdin)
dup_devnull(0);
else if (need_in) {
@@ -152,9 +271,15 @@ fail_pipe:
close(cmd->out);
}
- if (cmd->dir && chdir(cmd->dir))
- die_errno("exec '%s': cd to '%s' failed", cmd->argv[0],
- cmd->dir);
+ if (cmd->dir && chdir(cmd->dir)) {
+ failed_errno = errno;
+ error_child("exec '%s': cd to '%s' failed: %s",
+ cmd->argv[0], cmd->dir, strerror(errno));
+ trace_printf("trace: exec '%s': cd to '%s' failed: %s\n",
+ cmd->argv[0], cmd->dir, strerror(errno));
+ errored = 1;
+ goto throw_fault;
+ }
if (cmd->env) {
for (; *cmd->env; cmd->env++) {
if (strchr(*cmd->env, '='))
@@ -163,8 +288,23 @@ fail_pipe:
unsetenv(*cmd->env);
}
}
- if (cmd->preexec_cb)
+ if (cmd->preexec_cb) {
+ /*
+ * We don't know what pre-exec callbacks do, and they
+ * may do something that causes deadlock with exec
+ * reporting. The sole user of this hook seems to
+ * be pager, and it is run through shell, so one
+ * wouldn't get useful error from exec reporting
+ * and would get useful error from shell anyway. So
+ * just disable exec reporting for such comamnds.
+ * (unless explicitly specified otherwise).
+ */
+ if (!cmd->report_preexec_cb) {
+ force_close(report_pipe[1]);
+ report_pipe[1] = -1;
+ }
cmd->preexec_cb();
+ }
if (cmd->git_cmd) {
execv_git_cmd(cmd->argv);
} else if (cmd->use_shell) {
@@ -172,13 +312,36 @@ fail_pipe:
} else {
execvp(cmd->argv[0], (char *const*) cmd->argv);
}
+ failed_errno = errno;
+
trace_printf("trace: exec '%s' failed: %s\n", cmd->argv[0],
strerror(errno));
- exit(127);
- }
- if (cmd->pid < 0)
+
+ if (!cmd->silent_exec_failure || errno != ENOENT)
+ error_child("cannot exec '%s': %s",
+ cmd->argv[0], strerror(failed_errno));
+throw_fault:
+ r = 0;
+write_again:
+ if (report_pipe[1] >= 0)
+ r = write(report_pipe[1], &failed_errno,
+ sizeof(failed_errno));
+ if (r < 0 && (errno == EAGAIN || errno == EINTR ||
+ errno == EWOULDBLOCK))
+ goto write_again;
+
+ /*
+ * Diffrentiate between program doesn't exist and other
+ * errors.
+ */
+ if (errored || errno != ENOENT)
+ exit(128);
+ else
+ exit(127);
+ } else if (cmd->pid < 0)
error("cannot fork() for %s: %s", cmd->argv[0],
strerror(failed_errno = errno));
+}
#else
{
int s0 = -1, s1 = -1, s2 = -1; /* backups of stdin, stdout, stderr */
@@ -233,6 +396,8 @@ fail_pipe:
failed_errno = errno;
if (cmd->pid < 0 && (!cmd->silent_exec_failure || errno != ENOENT))
error("cannot spawn %s: %s", cmd->argv[0], strerror(errno));
+ if (cmd->pid < 0 && errno == ENOENT)
+ func_ret = -2;
if (cmd->env)
free_environ(env);
@@ -261,7 +426,10 @@ fail_pipe:
if (need_err)
close_pair(fderr);
errno = failed_errno;
- return -1;
+ if (cmd->extended_error_code && func_ret)
+ return func_ret;
+ else
+ return -1;
}
if (need_in)
@@ -280,7 +448,8 @@ fail_pipe:
return 0;
}
-static int wait_or_whine(pid_t pid, const char *argv0, int silent_exec_failure)
+static int wait_or_whine(pid_t pid, const char *argv0, int silent_exec_failure,
+ int extended_err)
{
int status, code = -1;
pid_t waiting;
@@ -309,7 +478,7 @@ static int wait_or_whine(pid_t pid, const char *argv0, int silent_exec_failure)
* Convert special exit code when execvp failed.
*/
if (code == 127) {
- code = -1;
+ code = extended_err ? -2 : -1;
failed_errno = ENOENT;
if (!silent_exec_failure)
error("cannot run %s: %s", argv0,
@@ -324,7 +493,8 @@ static int wait_or_whine(pid_t pid, const char *argv0, int silent_exec_failure)
int finish_command(struct child_process *cmd)
{
- return wait_or_whine(cmd->pid, cmd->argv[0], cmd->silent_exec_failure);
+ return wait_or_whine(cmd->pid, cmd->argv[0], cmd->silent_exec_failure,
+ cmd->extended_error_code);
}
int run_command(struct child_process *cmd)
@@ -410,7 +580,7 @@ int start_async(struct async *async)
int finish_async(struct async *async)
{
#ifndef WIN32
- int ret = wait_or_whine(async->pid, "child process", 0);
+ int ret = wait_or_whine(async->pid, "child process", 0, 0);
#else
DWORD ret = 0;
if (WaitForSingleObject(async->tid, INFINITE) != WAIT_OBJECT_0)
diff --git a/run-command.h b/run-command.h
index 967ba8c..f6b4caf 100644
--- a/run-command.h
+++ b/run-command.h
@@ -34,6 +34,8 @@ struct child_process {
unsigned silent_exec_failure:1;
unsigned stdout_to_stderr:1;
unsigned use_shell:1;
+ unsigned extended_error_code:1;
+ unsigned report_preexec_cb:1;
void (*preexec_cb)(void);
};
diff --git a/t/t0061-run-command.sh b/t/t0061-run-command.sh
new file mode 100755
index 0000000..0c217b1
--- /dev/null
+++ b/t/t0061-run-command.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+#
+# Copyright (c) 2009 Ilari Liusvaara
+#
+
+test_description='Test run command'
+
+. ./test-lib.sh
+
+test_expect_success "reporting ENOENT (non-extended)" \
+"test-run-command 2"
+
+test_expect_success "reporting ENOENT (extended)" \
+"test-run-command 1"
+
+test_expect_success "reporting chdir failed (extended)" \
+"test-run-command 3"
+
+
+test_done
diff --git a/test-run-command.c b/test-run-command.c
new file mode 100644
index 0000000..db664f3
--- /dev/null
+++ b/test-run-command.c
@@ -0,0 +1,74 @@
+/*
+ * test-run-command.c: test run command API.
+ *
+ * (C) 2009 Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
+ *
+ * This code is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "git-compat-util.h"
+#include "run-command.h"
+#include <string.h>
+#include <errno.h>
+
+int main(int argc, char **argv)
+{
+ char* procs[2];
+ struct child_process proc;
+ char test = argv[1][0];
+ memset(&proc, 0, sizeof(proc));
+
+ if(argc < 2)
+ return 1;
+
+
+ switch(test) {
+ case '1':
+ procs[0] = "does-not-exist-62896869286";
+ procs[1] = NULL;
+ proc.argv = (const char **)procs;
+ proc.extended_error_code = 1;
+
+ if (start_command(&proc) != -2) {
+ fprintf(stderr, "FAIL A\n");
+ return 1;
+ }
+ if (test == '1' && errno == ENOENT)
+ return 0;
+ case '2':
+ procs[0] = "does-not-exist-62896869286";
+ procs[1] = NULL;
+ proc.argv = (const char **)procs;
+ proc.extended_error_code = 0;
+
+ if (start_command(&proc) != -1) {
+ fprintf(stderr, "FAIL A\n");
+ return 1;
+ }
+ if (errno == ENOENT)
+ return 0;
+ case '3':
+#ifdef WIN32
+ /* This can't work on Win32, so just skip it. */
+ return 0;
+#endif
+ procs[0] = "does-not-exist-62896869286";
+ procs[1] = NULL;
+ proc.argv = (const char **)procs;
+ proc.dir = "does-not-exist-52632632733";
+ proc.extended_error_code = 1;
+
+ if (start_command(&proc) != -1) {
+ fprintf(stderr, "FAIL A\n");
+ return 1;
+ }
+ if (errno == ENOENT)
+ return 0;
+ }
+
+ fprintf(stderr, "FAIL B\n");
+
+ return 1;
+}
--
1.6.6.3.gaa2e1
^ permalink raw reply related
* [RFC PATCH v2 2/2] Improve transport helper exec failure reporting
From: Ilari Liusvaara @ 2010-01-09 13:45 UTC (permalink / raw)
To: git
In-Reply-To: <1263044757-12560-1-git-send-email-ilari.liusvaara@elisanet.fi>
Previously transport-helper exec failure error reporting was pretty
much useless as it didn't report errors from execve, only from pipe
and fork. Now that run-command passes errno from exec, use the
improved support to actually print useful errors if execution fails.
Signed-off-by: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
---
transport-helper.c | 27 +++++++++++++++++++++++----
1 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/transport-helper.c b/transport-helper.c
index 5147296..72be965 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -102,6 +102,7 @@ static struct child_process *get_helper(struct transport *transport)
int refspec_nr = 0;
int refspec_alloc = 0;
int duped;
+ int code;
if (data->helper)
return data->helper;
@@ -111,13 +112,31 @@ static struct child_process *get_helper(struct transport *transport)
helper->out = -1;
helper->err = 0;
helper->argv = xcalloc(4, sizeof(*helper->argv));
- strbuf_addf(&buf, "remote-%s", data->name);
+ strbuf_addf(&buf, "git-remote-%s", data->name);
helper->argv[0] = strbuf_detach(&buf, NULL);
helper->argv[1] = transport->remote->name;
helper->argv[2] = remove_ext_force(transport->url);
- helper->git_cmd = 1;
- if (start_command(helper))
- die("Unable to run helper: git %s", helper->argv[0]);
+ helper->argv[2] = transport->url;
+ helper->git_cmd = 0;
+ helper->silent_exec_failure = 1;
+ helper->extended_error_code = 1;
+ /*
+ * Print errors even if start_command should have printed them in
+ * order to get proper fatal-level error message and include
+ * errnos to make inevitable incomplete problem reports more useful
+ * (those have nasty tendency of including only the last line that
+ * looks like error).
+ */
+ code = start_command(helper);
+ if (code == -2)
+ die("Unable to find remote helper for '%s'",
+ data->name);
+ else if(code == -1)
+ die_errno("Error running helper for '%s'", data->name);
+ else if(code != 0)
+ /* Shouldn't happen. */
+ die_errno("code %i running helper for '%s'", code, data->name);
+
data->helper = helper;
data->no_disconnect_req = 0;
--
1.6.6.3.gaa2e1
^ permalink raw reply related
* [RFC PATCH v2 0/2] Imporove remote helper exec failure reporting
From: Ilari Liusvaara @ 2010-01-09 13:45 UTC (permalink / raw)
To: git
(This is newer than updated patch v3).
I decided to go on a bit further with new features, and that's why this
is back as RFC.
Diffrences from first RFC round:
- Split loop-over-close to its own function and warn but not retry on
bizarre error codes (basically anything except EBADF and EINTR).
- Don't rely on pipe(2) to preserve the fd array on failure.
- Add some testcases.
- Fix buggy behaviour if report pipe read end winds up as fd #0.
- Set silent_exec_failure on executing remote helper.
- Make exec reporting in presence of preexec_cb controlled by flag to
solve pager deadlock problems without preventing using preexec_cb
with exec reporting entierely (the way pager is invoked is just
fundamentially incompatible with exec reporting).
- Add flag to make run-command give different code for exec failing due to
ENOENT than for other failures (including other ways to get ENOENT).
- change chdir failure to be reported as error (and pass error code back).
BTW: Nothing seems to use that chdir feature, aside of new testcase.
- Report errors to parent's stderr.
- Don't retry waitpid on bizarre error codes (basically anything except
EINTR).
- Make run_command actually complain about exec failing (as API docs
say).
Ilari Liusvaara (2):
Report exec errors from run-command
Improve transport helper exec failure reporting
Documentation/technical/api-run-command.txt | 2 +
Makefile | 1 +
run-command.c | 196 +++++++++++++++++++++++++--
run-command.h | 2 +
t/t0061-run-command.sh | 20 +++
test-run-command.c | 74 ++++++++++
transport-helper.c | 27 +++-
7 files changed, 305 insertions(+), 17 deletions(-)
create mode 100755 t/t0061-run-command.sh
create mode 100644 test-run-command.c
^ permalink raw reply
* Re: Filename quoting / parsing problem
From: Andreas Schwab @ 2010-01-06 10:06 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Andreas Gruenbacher, git
In-Reply-To: <7viqbgniq1.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
> So you can (and I think git-apply does) follow this simple rule:
>
> If you see +++/---/rename from/rename to/new file/deleted file, use
> the names you find there. Otherwise, because there is no rename,
> "diff --git" lines has two identical names that follow a/ and b/, so
> use that name.
If you use diff.mnemonicprefix=true then a/ and b/ may be different.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply
* Re: [PATCHv3 3/4 (resent)] gitweb: Optionally add "git" links in project list page
From: Jakub Narebski @ 2010-01-09 11:20 UTC (permalink / raw)
To: J.H.; +Cc: git, John 'Warthog9' Hawley
In-Reply-To: <4B47E06C.9070503@eaglescrag.net>
On Sat, 9 Jan 2010, J.H. wrote:
> On 01/03/2010 08:07 AM, Jakub Narebski wrote:
> > From: John 'Warthog9' Hawley <warthog9@kernel.org>
> >
> > This adds a "git" link for each project in the project list page,
> > should a common $gitlinkurl_base be defined and not empty. The full
> > URL of each link is composed of $gitlinkurl_base and project name.
> > It is intended for git:// links, and in fact GITWEB_BASE_URL build
> > variable is used as its default value only if it starts with git://
> >
> > This does make the assumption that the git repositories share a common
> > path. Nothing to date is known to actually make use of introduced
> > link.
> >
> > Created "git" link follows rel=vcs-* microformat specification:
> > http://kitenet.net/~joey/rfc/rel-vcs/
> >
> > Signed-off-by: John 'Warthog9' Hawley <warthog9@kernel.org>
> > Signed-off-by: Jakub Narebski <jnareb@gmail.com>
> > ---
> > I think it might be good idea... but for the fact "Nothing to date is
> > known to actually make use of introduced link". What's its intended
> > use?
> >
> > Differences to original version by John 'Warthog9' Hawley (J.H.):
> > * It doesn't cause syntax error ;-)
> > * Escaping of attribute value is left to CGI.pm (avoid double escaping)
> > * $gitlinkurl got renamed to $gitlinkurl_base, now includes git://
> > prefix, and defaults to GITWEB_BASE_URL if it begins with git://
> > * Added description of $gitlinkurl_base to gitweb/README
> > * Uses rel=vcs-* microformat by Joey Hess
> > gitweb/README | 4 ++++
> > gitweb/gitweb.perl | 8 ++++++++
> > 2 files changed, 12 insertions(+), 0 deletions(-)
A reminder - this patch series consists of the following patches:
[PATCHv2 1/4 (resent)] gitweb: Load checking
[RFC/PATCHv2 2/4 (resent)] gitweb: Add option to force version match
[PATCHv3 3/4 (resent)] gitweb: Optionally add "git" links in project list page
[PATCHv2/RFC 4/4 (resent)] gitweb: Makefile improvements
> Ok I've been debating this as I've been going through the patches, I've
> got small modifications on top of your patches Jakub for 1 and 2,
> haven't pushed them yet but they are relatively trivial. The changes to
> the first patch sets things up for additional load checkers to be added
> later on.
Good idea, although I think that such addition can be left for a separate
patch.
By the way, are you doing if-elsif fallback chain, trying different
mechanisms (like '/proc/loadavg', BSD::getloadavg, etc.), or did
you made get_loadavg() into code reference, i.e. run it with
$get_loadavg->(), which has the advantage that the gitweb admin can
override it in gitweb config file (including such thing like simply
using load average over last 5 minutes, and not over last minute)?
> The second changes the error message to use/abuse die_error()
> vs. doing it's own thing (though I still think this should be on by
> default).
True, the error message could use improvement (and not only using
its own class instead of abusing 'readme' class, or renaming 'readme'
class to something more generic). The problem with error message for
this is who is the target of this message: is it gitweb administrator
(who can change gitweb configuration), or is it gitweb user (who need
to contact web admin).
The problem with this patch is that for it to be useful for protecting
against silent errors it should be on by default, but OTOH having it on
by default is quite inconvenient.
Best solution would be to treat core of this issue, namely eliminate
silent errors and always provide some message in case of error.
> Patch 4 I don't have anything to add or change at this point.
>
> This patch has me pondering and I'm unsure of what I'd suggest, mainly
> because of the addition of the smart http support meaning that git://
> and http:// are legitimate and useful links for supporting full git
> transactions.
>
> I may withdraw the patch entirely since the link on kernel.org has been
> around for years, and I'm unsure if anything actually uses it (though I
> can see it being useful still). If it stays I think there's got to be a
> way to specifically mark a url as being the one to link to vs.
> defaulting to git:// (or allow for a marking to override the git://) and
> I need to ponder that.
Also, it has to be _fast_, I think, i.e. no reading cloneurl and repo
config (for gitweb.url) for each repository.
You can always remove the check for "git://" prefix, and/or take first
base in @git_base_url_list.
>
> I have given some initial thought to converting the $output options I'm
> currently using to a print <FH> that Jakub is suggesting & exploring.
It's 'print {$fh}', i.e. use indirect filehandle, not global filehandle.
> I think all told it's going to be a similarly sized patch, since all
> output still has to get adjusted (including the things that directly
> output but don't print).
print -> print {$fh} can be separate patch, and it can be checked that
it produces the same results. Well print -> $output .= could also be
separate patch...
> I'm unsure if there's a real advantage to
> either way, other than design preference. My patch (forcing the output
> to get passed around) moves towards more of a modal style design
> separating data & layout vs. it's combined nature now, well it's a step
> in that direction anyway.
Errr... what? Forcing buffering (you need to read whole output into
memory, including for snapshots (uncompressed in case of .tar.gz))
is IMVHO orthogonal to the issue of separating data & layout.
BTW. Modern web server interfaces like Rack, PSGI/Plack etc. explicitly
include streaming support.
The advantage of doing 'print {$fh}' is that $fh can be \*STDOUT, can
be \$buffer, but can be filehandle to (temporary) file on disk, and
you can even "tee" it, i.e. both write to memory/file, and to STDOUT.
The number of possible choices / possible improvements is much larger.
And what is also important it means that people who do not use caching
do not suffer latency penalty and memory pressure from caching
infrastructure they do not use.
P.S.
Subject: [Virus] Exploit.PDF-9669
X-Virus-Scanned: ClamAV 0.88.7/10275/Fri Jan 8 17:06:46 2010 on shards.monkeyblade.net
X-Virus-Status: Infected with Exploit.PDF-9669
X-Original-Subject: Re: [PATCHv3 3/4 (resent)] gitweb: Optionally add "git"
links in project list page
A message sent from <warthog9@eaglescrag.net> to
<jnareb@gmail.com>
<git@vger.kernel.org>
<warthog9@kernel.org>
contained Exploit.PDF-9669 and has not been delivered.
--
Jakub Narebski
Poland
^ permalink raw reply
* Re: [PATCH] Don't pass CFLAGS to the linker
From: Paolo Bonzini @ 2010-01-09 10:32 UTC (permalink / raw)
To: Tomas Carnecky; +Cc: git
In-Reply-To: <1261896918-1953-1-git-send-email-tom@dbservice.com>
On 12/27/2009 07:55 AM, Tomas Carnecky wrote:
> Signed-off-by: Tomas Carnecky<tom@dbservice.com>
> ---
>
> I don't remember exactly which tool had problems with CFLAGS being passed
> to the linker. Maybe it was the clang static analyzer, or some other
> tool that I let run on git.git. Anyway, I don't think there's any
> reason to pass CFLAGS to the linker.
One reason is if you want to use GCC's upcoming link-time optimization
(-flto).
Paolo
^ permalink raw reply
* Re: [PATCH] ls-files: fix overeager pathspec optimization
From: Junio C Hamano @ 2010-01-09 8:07 UTC (permalink / raw)
To: Linus Torvalds, Jeff King; +Cc: Michael J Gruber, Jon Schewe, spearce, git
In-Reply-To: <7veilzaguf.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
> Linus Torvalds <torvalds@linux-foundation.org> writes:
>
>> I'd have to see both patches to be able to tell. I do admit that while I
>> acked your patch, it sure ain't _pretty_ to do that special odd
>> "has_leading_ignored_dir()" thing.
>
> Revised patch (v4) series is coming shortly.
Having sent these patches, I am wondering if the simplest fix might be this
one-liner.
diff --git a/dir.c b/dir.c
index d0999ba..7fba335 100644
--- a/dir.c
+++ b/dir.c
@@ -788,3 +788,3 @@ int read_directory(struct dir_struct *dir, const char *path, int len, const char
simplify = create_simplify(pathspec);
- read_directory_recursive(dir, path, len, 0, simplify);
+ read_directory_recursive(dir, "", 0, 0, simplify);
free_simplify(simplify);
What my series does is to keep all the "depending on dir->flags and what
excluded() says for path, decide to recurse, add it to dir->ignored[],
etc." logic and optimize only the readdir() loop, pretending as if it
returned only the entry on the "common prefix" path and nothing else, as
we know all other paths will be skipped by either simplified away or
filtered by in_pathspec() check.
If the directories we are reading are not humongous, maybe using this much
simpler patch might be preferrable (although it is completely untested).
^ permalink raw reply related
* Bug#557477: git-svn: git svn dcommit doesn't handle network failure
From: Jonathan Nieder @ 2010-01-09 7:57 UTC (permalink / raw)
To: Eric Wong
Cc: Brice Goglin, 557477-forwarded, 557477, git, Alex Vandiver,
Pedro Melo, Sam Vilain
In-Reply-To: <20100109021347.GA26520@dcvr.yhbt.net>
Eric Wong wrote:
> I agree that error recovery for dcommit sucks right now.
>
> I think Brice's idea (creating a temporary branch to dcommit from)
> is easier to implement and less likely to break than automatically
> unapplying patches.
Sounds sane to me. Probably that temporary branch could just be
a detached HEAD.
Current dcommit:
diff-index --quiet HEAD || carp "Cannot dcommit with a dirty index"
if head ne 'HEAD':
save the old HEAD
check out the head
find svn upstream
decide what commits to push (linearize_history)
for each commit d to push:
commit diff from d~ to d to the remote repository
(this involves applying the diff locally?)
remember parents
fetch remote revision, using remembered parents for commit
unless args include --no-rebase:
rebase the current HEAD against fetched revision
(or reset if there are no changes)
update the list of commits to push
if head ne 'HEAD':
let the user know the branch or commit id for the finished dcommit
check out the old head again
If I understand you correctly, before finding the svn upstream,
dcommit would save the HEAD ref name (if any) and detach the HEAD;
after pushing the relevant commits, update that ref and reattach the
HEAD.
If pushing fails early, what should git-svn do? Leave the HEAD
detached, with a message suggesting to return to the old ref? Check
out the old ref, with a message suggesting to 'git svn rebase' and try
again? Do the 'git svn rebase' automatically?
I guess the safest option is the first one. That would at least be a
starting point for experimenting with more friendly behaviors.
I should also mention that there seems to be a little race here: if
git-svn dies before (or while) fetching the newly commited revision,
when it is fetched later it will have the wrong parents.
Jonathan
^ permalink raw reply
* [PATCH 4/4] ls-files: fix overeager pathspec optimization
From: Junio C Hamano @ 2010-01-09 7:35 UTC (permalink / raw)
To: git; +Cc: Linus Torvalds, Jeff King, Michael J Gruber, Jon Schewe, spearce
In-Reply-To: <1263022535-12822-1-git-send-email-gitster@pobox.com>
Given pathspecs that share a common prefix, ls-files optimized its call
into recursive directory reader by starting at the common prefix
directory.
If you have a directory "t" with an untracked file "t/junk" in it, but the
top-level .gitignore file told us to ignore "t/", this resulted in:
$ git ls-files -o --exclude-standard
$ git ls-files -o --exclude-standard t/
t/junk
$ git ls-files -o --exclude-standard t/junk
t/junk
$ cd t && git ls-files -o --exclude-standard
junk
We could argue that you are overriding the ignore file by giving a
patchspec that matches or being in that directory, but it is somewhat
unexpected. Worse yet, these behave differently:
$ git ls-files -o --exclude-standard t/ .
$ git ls-files -o --exclude-standard t/
t/junk
This patch changes the optimization so that it notices when the common
prefix directory that it starts reading from is an ignored one.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
dir.c | 38 +++++++++++++++++++++++++++++++++++-
t/t3001-ls-files-others-exclude.sh | 2 +-
2 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/dir.c b/dir.c
index 35cc89b..00d698d 100644
--- a/dir.c
+++ b/dir.c
@@ -813,6 +813,41 @@ static void free_simplify(struct path_simplify *simplify)
free(simplify);
}
+static int treat_leading_path(struct dir_struct *dir,
+ const char *path, int len,
+ const struct path_simplify *simplify)
+{
+ char pathbuf[PATH_MAX];
+ int baselen, blen;
+ const char *cp;
+
+ while (len && path[len - 1] == '/')
+ len--;
+ if (!len)
+ return 1;
+ baselen = 0;
+ while (1) {
+ cp = path + baselen + !!baselen;
+ cp = memchr(cp, '/', path + len - cp);
+ if (!cp)
+ baselen = len;
+ else
+ baselen = cp - path;
+ memcpy(pathbuf, path, baselen);
+ pathbuf[baselen] = '\0';
+ if (!is_directory(pathbuf))
+ return 0;
+ if (simplify_away(pathbuf, baselen, simplify))
+ return 0;
+ blen = baselen;
+ if (treat_one_path(dir, pathbuf, &blen, simplify,
+ DT_DIR, NULL) == path_ignored)
+ return 0; /* do not recurse into it */
+ if (len <= baselen)
+ return 1; /* finished checking */
+ }
+}
+
int read_directory(struct dir_struct *dir, const char *path, int len, const char **pathspec)
{
struct path_simplify *simplify;
@@ -821,7 +856,8 @@ int read_directory(struct dir_struct *dir, const char *path, int len, const char
return dir->nr;
simplify = create_simplify(pathspec);
- read_directory_recursive(dir, path, len, 0, simplify);
+ if (!len || treat_leading_path(dir, path, len, simplify))
+ read_directory_recursive(dir, path, len, 0, simplify);
free_simplify(simplify);
qsort(dir->entries, dir->nr, sizeof(struct dir_entry *), cmp_name);
qsort(dir->ignored, dir->ignored_nr, sizeof(struct dir_entry *), cmp_name);
diff --git a/t/t3001-ls-files-others-exclude.sh b/t/t3001-ls-files-others-exclude.sh
index e3e4d71..9e71260 100755
--- a/t/t3001-ls-files-others-exclude.sh
+++ b/t/t3001-ls-files-others-exclude.sh
@@ -183,7 +183,7 @@ test_expect_success 'subdirectory ignore (l1/l2)' '
test_cmp expect actual
'
-test_expect_failure 'subdirectory ignore (l1)' '
+test_expect_success 'subdirectory ignore (l1)' '
(
cd top/l1 &&
git ls-files -o --exclude-standard
--
1.6.6.209.g52296.dirty
^ permalink raw reply related
* [PATCH 3/4] read_directory(): further split treat_path()
From: Junio C Hamano @ 2010-01-09 7:35 UTC (permalink / raw)
To: git; +Cc: Linus Torvalds, Jeff King, Michael J Gruber, Jon Schewe, spearce
In-Reply-To: <1263022535-12822-1-git-send-email-gitster@pobox.com>
The next caller I'll be adding won't have an access to struct dirent
because it won't be reading from a directory stream. Split the main
part of the function further into a separate function to make it usable
by a caller without passing a dirent as long as it knows what type is
feeding the function.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
dir.c | 50 +++++++++++++++++++++++++++++---------------------
1 files changed, 29 insertions(+), 21 deletions(-)
diff --git a/dir.c b/dir.c
index dec8365..35cc89b 100644
--- a/dir.c
+++ b/dir.c
@@ -631,28 +631,12 @@ enum path_treatment {
path_recurse,
};
-static enum path_treatment treat_path(struct dir_struct *dir,
- struct dirent *de,
- char *path, int path_max,
- int baselen,
- const struct path_simplify *simplify,
- int *len)
+static enum path_treatment treat_one_path(struct dir_struct *dir,
+ char *path, int *len,
+ const struct path_simplify *simplify,
+ int dtype, struct dirent *de)
{
- int dtype, exclude;
-
- if (is_dot_or_dotdot(de->d_name) || !strcmp(de->d_name, ".git"))
- return path_ignored;
- *len = strlen(de->d_name);
- /* Ignore overly long pathnames! */
- if (*len + baselen + 8 > path_max)
- return path_ignored;
- memcpy(path + baselen, de->d_name, *len + 1);
- *len += baselen;
- if (simplify_away(path, *len, simplify))
- return path_ignored;
-
- dtype = DTYPE(de);
- exclude = excluded(dir, path, &dtype);
+ int exclude = excluded(dir, path, &dtype);
if (exclude && (dir->flags & DIR_COLLECT_IGNORED)
&& in_pathspec(path, *len, simplify))
dir_add_ignored(dir, path, *len);
@@ -703,6 +687,30 @@ static enum path_treatment treat_path(struct dir_struct *dir,
return path_handled;
}
+static enum path_treatment treat_path(struct dir_struct *dir,
+ struct dirent *de,
+ char *path, int path_max,
+ int baselen,
+ const struct path_simplify *simplify,
+ int *len)
+{
+ int dtype;
+
+ if (is_dot_or_dotdot(de->d_name) || !strcmp(de->d_name, ".git"))
+ return path_ignored;
+ *len = strlen(de->d_name);
+ /* Ignore overly long pathnames! */
+ if (*len + baselen + 8 > path_max)
+ return path_ignored;
+ memcpy(path + baselen, de->d_name, *len + 1);
+ *len += baselen;
+ if (simplify_away(path, *len, simplify))
+ return path_ignored;
+
+ dtype = DTYPE(de);
+ return treat_one_path(dir, path, len, simplify, dtype, de);
+}
+
/*
* Read a directory tree. We currently ignore anything but
* directories, regular files and symlinks. That's because git
--
1.6.6.209.g52296.dirty
^ permalink raw reply related
* [PATCH 2/4] read_directory_recursive(): refactor handling of a single path into a separate function
From: Junio C Hamano @ 2010-01-09 7:35 UTC (permalink / raw)
To: git; +Cc: Linus Torvalds, Jeff King, Michael J Gruber, Jon Schewe, spearce
In-Reply-To: <1263022535-12822-1-git-send-email-gitster@pobox.com>
Primarily because I want to reuse it in a separate function later,
but this de-dents a huge function by one tabstop which by itself is
an improvement as well.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
dir.c | 153 ++++++++++++++++++++++++++++++++++++++---------------------------
1 files changed, 90 insertions(+), 63 deletions(-)
diff --git a/dir.c b/dir.c
index d0999ba..dec8365 100644
--- a/dir.c
+++ b/dir.c
@@ -625,6 +625,84 @@ static int get_dtype(struct dirent *de, const char *path, int len)
return dtype;
}
+enum path_treatment {
+ path_ignored,
+ path_handled,
+ path_recurse,
+};
+
+static enum path_treatment treat_path(struct dir_struct *dir,
+ struct dirent *de,
+ char *path, int path_max,
+ int baselen,
+ const struct path_simplify *simplify,
+ int *len)
+{
+ int dtype, exclude;
+
+ if (is_dot_or_dotdot(de->d_name) || !strcmp(de->d_name, ".git"))
+ return path_ignored;
+ *len = strlen(de->d_name);
+ /* Ignore overly long pathnames! */
+ if (*len + baselen + 8 > path_max)
+ return path_ignored;
+ memcpy(path + baselen, de->d_name, *len + 1);
+ *len += baselen;
+ if (simplify_away(path, *len, simplify))
+ return path_ignored;
+
+ dtype = DTYPE(de);
+ exclude = excluded(dir, path, &dtype);
+ if (exclude && (dir->flags & DIR_COLLECT_IGNORED)
+ && in_pathspec(path, *len, simplify))
+ dir_add_ignored(dir, path, *len);
+
+ /*
+ * Excluded? If we don't explicitly want to show
+ * ignored files, ignore it
+ */
+ if (exclude && !(dir->flags & DIR_SHOW_IGNORED))
+ return path_ignored;
+
+ if (dtype == DT_UNKNOWN)
+ dtype = get_dtype(de, path, *len);
+
+ /*
+ * Do we want to see just the ignored files?
+ * We still need to recurse into directories,
+ * even if we don't ignore them, since the
+ * directory may contain files that we do..
+ */
+ if (!exclude && (dir->flags & DIR_SHOW_IGNORED)) {
+ if (dtype != DT_DIR)
+ return path_ignored;
+ }
+
+ switch (dtype) {
+ default:
+ return path_ignored;
+ case DT_DIR:
+ memcpy(path + *len, "/", 2);
+ (*len)++;
+ switch (treat_directory(dir, path, *len, simplify)) {
+ case show_directory:
+ if (exclude != !!(dir->flags
+ & DIR_SHOW_IGNORED))
+ return path_ignored;
+ break;
+ case recurse_into_directory:
+ return path_recurse;
+ case ignore_directory:
+ return path_ignored;
+ }
+ break;
+ case DT_REG:
+ case DT_LNK:
+ break;
+ }
+ return path_handled;
+}
+
/*
* Read a directory tree. We currently ignore anything but
* directories, regular files and symlinks. That's because git
@@ -634,7 +712,10 @@ static int get_dtype(struct dirent *de, const char *path, int len)
* Also, we ignore the name ".git" (even if it is not a directory).
* That likely will not change.
*/
-static int read_directory_recursive(struct dir_struct *dir, const char *base, int baselen, int check_only, const struct path_simplify *simplify)
+static int read_directory_recursive(struct dir_struct *dir,
+ const char *base, int baselen,
+ int check_only,
+ const struct path_simplify *simplify)
{
DIR *fdir = opendir(*base ? base : ".");
int contents = 0;
@@ -645,70 +726,16 @@ static int read_directory_recursive(struct dir_struct *dir, const char *base, in
memcpy(path, base, baselen);
while ((de = readdir(fdir)) != NULL) {
- int len, dtype;
- int exclude;
-
- if (is_dot_or_dotdot(de->d_name) ||
- !strcmp(de->d_name, ".git"))
- continue;
- len = strlen(de->d_name);
- /* Ignore overly long pathnames! */
- if (len + baselen + 8 > sizeof(path))
+ int len;
+ switch (treat_path(dir, de, path, sizeof(path),
+ baselen, simplify, &len)) {
+ case path_recurse:
+ contents += read_directory_recursive
+ (dir, path, len, 0, simplify);
continue;
- memcpy(path + baselen, de->d_name, len+1);
- len = baselen + len;
- if (simplify_away(path, len, simplify))
+ case path_ignored:
continue;
-
- dtype = DTYPE(de);
- exclude = excluded(dir, path, &dtype);
- if (exclude && (dir->flags & DIR_COLLECT_IGNORED)
- && in_pathspec(path, len, simplify))
- dir_add_ignored(dir, path,len);
-
- /*
- * Excluded? If we don't explicitly want to show
- * ignored files, ignore it
- */
- if (exclude && !(dir->flags & DIR_SHOW_IGNORED))
- continue;
-
- if (dtype == DT_UNKNOWN)
- dtype = get_dtype(de, path, len);
-
- /*
- * Do we want to see just the ignored files?
- * We still need to recurse into directories,
- * even if we don't ignore them, since the
- * directory may contain files that we do..
- */
- if (!exclude && (dir->flags & DIR_SHOW_IGNORED)) {
- if (dtype != DT_DIR)
- continue;
- }
-
- switch (dtype) {
- default:
- continue;
- case DT_DIR:
- memcpy(path + len, "/", 2);
- len++;
- switch (treat_directory(dir, path, len, simplify)) {
- case show_directory:
- if (exclude != !!(dir->flags
- & DIR_SHOW_IGNORED))
- continue;
- break;
- case recurse_into_directory:
- contents += read_directory_recursive(dir,
- path, len, 0, simplify);
- continue;
- case ignore_directory:
- continue;
- }
- break;
- case DT_REG:
- case DT_LNK:
+ case path_handled:
break;
}
contents++;
--
1.6.6.209.g52296.dirty
^ permalink raw reply related
* [PATCH 1/4] t3001: test ls-files -o ignored/dir
From: Junio C Hamano @ 2010-01-09 7:35 UTC (permalink / raw)
To: git; +Cc: Linus Torvalds, Jeff King, Michael J Gruber, Jon Schewe, spearce
In-Reply-To: <7veilzaguf.fsf@alter.siamese.dyndns.org>
When you have "t" directory that is marked as ignored in the top-level
.gitignore file (or $GIT_DIR/info/exclude), running
$ git ls-files -o --exclude-standard
from the top-level correctly excludes files in "t" directory, but
any of the following:
$ git ls-files -o --exclude-standard t/
$ cd t && git ls-files -o --exclude-standard
would show untracked files in that directory.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
t/t3001-ls-files-others-exclude.sh | 39 ++++++++++++++++++++++++++++++++++++
1 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/t/t3001-ls-files-others-exclude.sh b/t/t3001-ls-files-others-exclude.sh
index c65bca8..e3e4d71 100755
--- a/t/t3001-ls-files-others-exclude.sh
+++ b/t/t3001-ls-files-others-exclude.sh
@@ -153,4 +153,43 @@ test_expect_success 'negated exclude matches can override previous ones' '
grep "^a.1" output
'
+test_expect_success 'subdirectory ignore (setup)' '
+ mkdir -p top/l1/l2 &&
+ (
+ cd top &&
+ git init &&
+ echo /.gitignore >.gitignore &&
+ echo l1 >>.gitignore &&
+ echo l2 >l1/.gitignore &&
+ >l1/l2/l1
+ )
+'
+
+test_expect_success 'subdirectory ignore (toplevel)' '
+ (
+ cd top &&
+ git ls-files -o --exclude-standard
+ ) >actual &&
+ >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success 'subdirectory ignore (l1/l2)' '
+ (
+ cd top/l1/l2 &&
+ git ls-files -o --exclude-standard
+ ) >actual &&
+ >expect &&
+ test_cmp expect actual
+'
+
+test_expect_failure 'subdirectory ignore (l1)' '
+ (
+ cd top/l1 &&
+ git ls-files -o --exclude-standard
+ ) >actual &&
+ >expect &&
+ test_cmp expect actual
+'
+
test_done
--
1.6.6.209.g52296.dirty
^ permalink raw reply related
* Re: [PATCH] ls-files: fix overeager pathspec optimization
From: Junio C Hamano @ 2010-01-09 7:16 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Jeff King, Michael J Gruber, Jon Schewe, spearce, git
In-Reply-To: <alpine.LFD.2.00.1001081701570.7821@localhost.localdomain>
Linus Torvalds <torvalds@linux-foundation.org> writes:
> I'd have to see both patches to be able to tell. I do admit that while I
> acked your patch, it sure ain't _pretty_ to do that special odd
> "has_leading_ignored_dir()" thing.
Revised patch (v4) series is coming shortly.
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox