* Re: [PATCH] Highlight keyboard shortcuts in git-add--interactive
From: Dan Zwell @ 2007-11-21 23:00 UTC (permalink / raw)
To: Jeff King; +Cc: Wincent Colaiuta, Dan Zwell, git, gitster
In-Reply-To: <20071121152817.GA27144@sigill.intra.peff.net>
Jeff King wrote:
> Dan, any progress on the next revision of the patch
> series?
>
Yeah, I've been busy with school work, but Thanksgiving break has just
started. I hope to have something to send tonight, though it probably
will not be the final draft, as it has quite a bit of changes from the
last version.
Dan
^ permalink raw reply
* Re: [StGit PATCH] Added test case for stg refresh
From: Karl Hasselström @ 2007-11-21 23:15 UTC (permalink / raw)
To: David Kågedal; +Cc: Git Mailing List, Catalin Marinas
In-Reply-To: <87oddnvpzf.fsf@virtutech.se>
On 2007-11-21 11:43:00 +0100, David Kågedal wrote:
> David Kågedal <davidk@lysator.liu.se> writes:
>
> > This test case fails on the kha/experimental branch. Using "stg
> > refresh -p <patch>" can cause all sorts of wieirdness, and there
> > is no test case for it.
>
> I just checked, and it fails on kha/safe as well. So maybe there is
> some problem with the test case, but I don't know what it is.
Thanks, more tests are always welcome. But it doesn't fail for me.
I've just pushed out updated kha/safe and kha/experimental branches --
with this new test at the bottom of the stack -- and the whole test
suite passes at every step. Could you try the updated branches and see
if you can still make it fail?
> And maybe it should be called t2301 instead?
Those numbers are just one big jumble anyway, so no need to bother.
:-)
--
Karl Hasselström, kha@treskal.com
www.treskal.com/kalle
^ permalink raw reply
* Re: [StGit PATCH] Added test case for stg refresh
From: Catalin Marinas @ 2007-11-21 23:31 UTC (permalink / raw)
To: Karl Hasselström; +Cc: David Kågedal, Git Mailing List
In-Reply-To: <20071121231553.GA19422@diana.vm.bytemark.co.uk>
On 21/11/2007, Karl Hasselström <kha@treskal.com> wrote:
> On 2007-11-21 11:43:00 +0100, David Kågedal wrote:
>
> > David Kågedal <davidk@lysator.liu.se> writes:
> >
> > > This test case fails on the kha/experimental branch. Using "stg
> > > refresh -p <patch>" can cause all sorts of wieirdness, and there
> > > is no test case for it.
I noticed the weirdness few days ago and fixed it in
e8813959aa3a7c41ffef61d06068b10519bd4830 (though no test caught it).
Do you still see problems after this commit?
--
Catalin
^ permalink raw reply
* Re: Git Screencast ?
From: Michael Donaghy @ 2007-11-21 23:45 UTC (permalink / raw)
To: git
In-Reply-To: <fi1a9f$30q$1@ger.gmane.org>
John Herland Said:
> There's a company called PeepCode that apparently sell a Git
> screencast, but
> I have no idea if it demonstrates advanced features, or just do the
> basics.
>
> There seems to be a TOC on their website, so you can check that to
see > if
> contains what you need:
>
> http://peepcode.com/products/git
>
>
> Have fun!
Peepcode has some really good quality screen casts ,yes, but they are
for pay , $10 per screen cast
and my original message said
>> "..is there a screencast of git somewhere (for free) that can
>> demonstrate some of the advanced features of git..."
Also thanks Johannes for that link , I will tak e a look at that
and Randal...
you are *EVERYWHERE* ... how do you do that ... , keep up the good work
=) (see you in the irc --Ekim)
^ permalink raw reply
* Re: [StGit PATCH] Added test case for stg refresh
From: Karl Hasselström @ 2007-11-21 23:55 UTC (permalink / raw)
To: Catalin Marinas; +Cc: David Kågedal, Git Mailing List
In-Reply-To: <b0943d9e0711211531v2f7b9c0bl99033c0bd58971c7@mail.gmail.com>
On 2007-11-21 23:31:45 +0000, Catalin Marinas wrote:
> I noticed the weirdness few days ago and fixed it in
> e8813959aa3a7c41ffef61d06068b10519bd4830 (though no test caught it).
> Do you still see problems after this commit?
Confirmed: the test fails before e8813959, and succeeds afterwards.
(You can pull the test from
git://repo.or.cz/stgit/kha.git safe
if you like.)
--
Karl Hasselström, kha@treskal.com
www.treskal.com/kalle
^ permalink raw reply
* [PATCH 1/4] Suppress spurious linefeeds in git-add--interactive
From: Wincent Colaiuta @ 2007-11-22 0:02 UTC (permalink / raw)
To: git; +Cc: gitster, peff, Wincent Colaiuta
In-Reply-To: <1195689773-28601-1-git-send-email-win@wincent.com>
Eliminate the spurious linefeed echoed to the terminal when passing an
untracked or unchanged file as a parameter to git-add--interactive.
Signed-off-by: Wincent Colaiuta <win@wincent.com>
---
git-add--interactive.perl | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 8f21c03..95e537c 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -336,6 +336,7 @@ sub add_untracked_cmd {
sub parse_diff {
my ($path) = @_;
my @diff = run_cmd_pipe(qw(git diff-files -p --), $path);
+ return undef if ($#diff == -1);
my (@hunk) = { TEXT => [] };
for (@diff) {
@@ -571,6 +572,7 @@ sub patch_update_file {
my ($ix, $num);
my $path = shift;
my ($head, @hunk) = parse_diff($path);
+ return unless $head;
for (@{$head->{TEXT}}) {
print;
}
--
1.5.3.6.867.g539b6-dirty
^ permalink raw reply related
* Updates: teaching git-add--interactive to accept a file param
From: Wincent Colaiuta @ 2007-11-22 0:02 UTC (permalink / raw)
To: git; +Cc: gitster, peff
In-Reply-To: <C6E820C8-91E9-48B2-9219-377CA83163A7@wincent.com>
Here are some incremental updates incorporating the feedback received on the
patch series that I sent earlier today. These apply on top of the previous
patches; when this series matures I'll rebase and squash this down to a
smaller number of commits, but for the timebeing I think it's clearer if I
post these modifications separately so they can be reviewed in themselves.
The modifications are:
Suppress spurious linefeeds in git-add--interactive
Teach git-add--interactive to accept multiple file params
Teach builtin-add to pass multiple paths to git-add--interactive
Update git-add documentation for multiple interactive paths
Next step will be to follow-up on Junio's suggestion that we should support
directory paths, not just file paths, and replicate the semantics of
non-interactive git-add.
Documentation/git-add.txt | 4 ++--
builtin-add.c | 23 +++++++++++++----------
commit.h | 2 +-
git-add--interactive.perl | 5 ++---
4 files changed, 18 insertions(+), 16 deletions(-)
^ permalink raw reply
* [PATCH 4/4] Update git-add documentation for multiple interactive paths
From: Wincent Colaiuta @ 2007-11-22 0:02 UTC (permalink / raw)
To: git; +Cc: gitster, peff, Wincent Colaiuta
In-Reply-To: <1195689773-28601-4-git-send-email-win@wincent.com>
Tweak the documentation to reflect that git-add--interactive can now
accept multiple path parameters.
Signed-off-by: Wincent Colaiuta <win@wincent.com>
---
Documentation/git-add.txt | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
index 4b44802..0675dbe 100644
--- a/Documentation/git-add.txt
+++ b/Documentation/git-add.txt
@@ -61,9 +61,9 @@ OPTIONS
-i, \--interactive::
Add modified contents in the working tree interactively to
- the index. If a single optional file argument is supplied the
+ the index. If optional path arguments are supplied the
initial command loop is bypassed and the 'patch' subcommand is
- invoked for the specified file. See ``Interactive mode'' below
+ invoked for each specified path. See ``Interactive mode'' below
for details.
-u::
--
1.5.3.6.867.g539b6-dirty
^ permalink raw reply related
* [PATCH 2/4] Teach git-add--interactive to accept multiple file params
From: Wincent Colaiuta @ 2007-11-22 0:02 UTC (permalink / raw)
To: git; +Cc: gitster, peff, Wincent Colaiuta
In-Reply-To: <1195689773-28601-2-git-send-email-win@wincent.com>
As per Jeff King's suggestion, this commit teaches git-add--interactive
to accept multiple optional file parameters, which will be fed into the
"patch" subcommand one by one. After all parameters are processed we
drop back into the standard command loop.
Signed-off-by: Wincent Colaiuta <win@wincent.com>
---
git-add--interactive.perl | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 95e537c..2bba07d 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -805,10 +805,9 @@ sub main_loop {
}
}
-die "add --interactive may take only 1 optional parameter" if ($#ARGV > 0);
refresh();
-if ($#ARGV == 0) {
- patch_update_file($ARGV[0]);
+foreach my $file (@ARGV) {
+ patch_update_file($file);
}
status_cmd();
main_loop();
--
1.5.3.6.867.g539b6-dirty
^ permalink raw reply related
* [PATCH 3/4] Teach builtin-add to pass multiple paths to git-add--interactive
From: Wincent Colaiuta @ 2007-11-22 0:02 UTC (permalink / raw)
To: git; +Cc: gitster, peff, Wincent Colaiuta
In-Reply-To: <1195689773-28601-3-git-send-email-win@wincent.com>
Instead of just accepting a single file parameter, git-add now accepts
any number of path parameters, fowarding them to git-add--interactive.
Signed-off-by: Wincent Colaiuta <win@wincent.com>
---
builtin-add.c | 23 +++++++++++++----------
commit.h | 2 +-
2 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/builtin-add.c b/builtin-add.c
index 278c02e..13f27e8 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -135,11 +135,17 @@ static void refresh(int verbose, const char **pathspec)
free(seen);
}
-int interactive_add(const char *path)
+int interactive_add(const char **argv, int argc)
{
- const char *argv[3] = { "add--interactive", path, NULL };
-
- return run_command_v_opt(argv, RUN_GIT_CMD);
+ int status;
+ const char **args = xmalloc(sizeof(const char *) * (argc + 1));
+ args[0] = "add--interactive";
+ memcpy((void *)args + sizeof(const char *), argv, sizeof(const char *) * argc);
+ args[argc + 1] = NULL;
+
+ status = run_command_v_opt(args, RUN_GIT_CMD);
+ free(args);
+ return status;
}
static struct lock_file lock_file;
@@ -170,13 +176,10 @@ int cmd_add(int argc, const char **argv, const char *prefix)
argc = parse_options(argc, argv, builtin_add_options,
builtin_add_usage, 0);
if (add_interactive) {
- if (argc > 1)
- die("add --interactive may take only 1 optional "
- "parameter");
- else if (argc == 1)
- exit(interactive_add(argv[0]));
+ if (argc > 0)
+ exit(interactive_add(argv, argc));
else
- exit(interactive_add(NULL));
+ exit(interactive_add(NULL, 0));
}
git_config(git_default_config);
diff --git a/commit.h b/commit.h
index 03a6ec5..3a398fc 100644
--- a/commit.h
+++ b/commit.h
@@ -113,7 +113,7 @@ extern struct commit_list *get_shallow_commits(struct object_array *heads,
int in_merge_bases(struct commit *, struct commit **, int);
-extern int interactive_add(const char *path);
+extern int interactive_add(const char **argv, int argc);
extern void add_files_to_cache(int verbose, const char *prefix, const char **files);
extern int rerere(void);
--
1.5.3.6.867.g539b6-dirty
^ permalink raw reply related
* Re: [PATCH 2/4] Teach git-add--interactive to accept a file path to patch
From: Junio C Hamano @ 2007-11-22 0:18 UTC (permalink / raw)
To: Wincent Colaiuta; +Cc: Jeff King, git
In-Reply-To: <C6E820C8-91E9-48B2-9219-377CA83163A7@wincent.com>
Wincent Colaiuta <win@wincent.com> writes:
> - Junio, do you mean to suggest with your comment that when passing
> untracked files either directly or indirectly (ie. when passing a dir
> containing untracked files) that they should be added (ie. invoked the
> "add untracked" subcommand) in addition to running the "patch"
> subcommand on the changed files?
What I meant was that if "git add -i" (unrestricted) shows paths
from a set A, "git add -i paths..." should show paths from a
subset of the set A and that subset should be defined with the
existing ls-files pathspec semantics.
For example, if "(a)dd untracked" subcommand shows all untracked
files when "add -i" was invoked without paths limitation, the
restricted form "add -i paths..." would show only untracked paths
that match the given set of patterns. If "(p)atch" subcommand
shows all modified tracked files when "add -i" was invoked
without paths limitation, the restricted form "add -i paths..."
would show only such modified tracked files whose names match
the given set of patterns.
^ permalink raw reply
* Addendum to "MaintNotes"
From: Junio C Hamano @ 2007-11-22 0:32 UTC (permalink / raw)
To: Git Mailing List; +Cc: Ping Yin
In-Reply-To: <46dff0320711210511g7d9febf5k47b082cc13bb905a@mail.gmail.com>
The maintainer's git time is spent on three activities.
- Communication (60%)
Mailing list discussions on general design, fielding user
questions, diagnosing bug reports; reviewing, commenting on,
suggesting alternatives to, and rejecting patches.
- Integration (30%)
Applying new patches from the contributors while spotting and
correcting minor mistakes, shuffling the integration and
testing branches, pushing the results out, cutting the
release, and making announcements.
- Own development (10%)
Scratching my own itch and sending proposed patch series out.
The policy on Integration is informally mentioned in "A Note
from the maintainer" message, which is periodically posted to
this mailing list after each feature release is made.
The policy.
- Feature releases are numbered as vX.Y.Z and are meant to
contain bugfixes and enhancements in any area, including
functionality, performance and usability, without regression.
- Maintenance releases are numbered as vX.Y.Z.W and are meant
to contain only bugfixes for the corresponding vX.Y.Z feature
release and earlier maintenance releases vX.Y.Z.V (V < W).
- 'master' branch is used to prepare for the next feature
release. In other words, at some point, the tip of 'master'
branch is tagged with vX.Y.Z.
- 'maint' branch is used to prepare for the next maintenance
release. After the feature release vX.Y.Z is made, the tip
of 'maint' branch is set to that release, and bugfixes will
accumulate on the branch, and at some point, the tip of the
branch is tagged with vX.Y.Z.1, vX.Y.Z.2, and so on.
- 'next' branch is used to publish changes (both enhancements
and fixes) that (1) have worthwhile goal, (2) are in a fairly
good shape suitable for everyday use, (3) but have not yet
demonstrated to be regression free. New changes are tested
in 'next' before merged to 'master'.
- 'pu' branch is used to publish other proposed changes that do
not yet pass the criteria set for 'next'.
- The tips of 'master', 'maint' and 'next' branches will always
fast forward, to allow people to build their own
customization on top of them.
- Usually 'master' contains all of 'maint', 'next' contains all
of 'master' and 'pu' contains all of 'next'.
- The tip of 'master' is meant to be more stable than any
tagged releases, and the users are encouraged to follow it.
- The 'next' branch is where new action takes place, and the
users are encouraged to test it so that regressions and bugs
are found before new topics are merged to 'master'.
A typical git day for the maintainer implements the above policy
by doing the following:
- Scan mailing list and #git channel log. Respond with review
comments, suggestions etc. Kibitz. Collect potentially
usable patches from the mailing list. Patches about a single
topic go to one mailbox (I read my mail in Gnus, and type
\C-o to save/append messages in files in mbox format).
- Review the patches in the saved mailboxes. Edit proposed log
message for typofixes and clarifications, and add Acks
collected from the list. Edit patch to incorporate "Oops,
that should have been like this" fixes from the discussion.
- Classify the collected patches and handle 'master' and
'maint' updates:
- Obviously correct fixes that pertain to the tip of 'maint'
are directly applied to 'maint'.
- Obviously correct fixes that pertain to the tip of 'master'
are directly applied to 'master'.
This step is done with "git am".
$ git checkout maint ;# or "git checkout maint"
$ git am -3 -s mailbox
$ make test
- Merge downwards (maint->master):
$ git checkout master
$ git merge maint
$ make test
- Review the last issue of "What's cooking" message, review the
topics scheduled for merging upwards (topic->master and
topic->maint), and merge.
$ git checkout master ;# or "git checkout maint"
$ git merge ai/topic ;# or "git merge ai/maint-topic"
$ git log -p ORIG_HEAD.. ;# final review
$ git diff ORIG_HEAD.. ;# final review
$ make test ;# final review
$ git branch -d ai/topic ;# or "git branch -d ai/maint-topic"
- Merge downwards (maint->master) if needed:
$ git checkout master
$ git merge maint
$ make test
- Merge downwards (master->next) if needed:
$ git checkout next
$ git merge master
$ make test
- Handle the remaining patches:
- Anything unobvious that is applicable to 'master' (in other
words, does not depend on anything that is still in 'next'
and not in 'master') is applied to a new topic branch that
is forked from the tip of 'master'. This includes both
enhancements and unobvious fixes to 'master'. A topic
branch is named as ai/topic where "ai" is typically
author's initial and "topic" is a descriptive name of the
topic (in other words, "what's the series is about").
- An unobvious fix meant for 'maint' is applied to a new
topic branch that is forked from the tip of 'maint'. The
topic is named as ai/maint-topic.
- Changes that pertain to an existing topic are applied to
the branch, but:
- obviously correct ones are applied first;
- questionable ones are discarded or applied to near the tip;
- Replacement patches to an existing topic are accepted only
for commits not in 'next'.
The above except the "replacement" are all done with:
$ git am -3 -s mailbox
while patch replacement is often done by:
$ git format-patch ai/topic~$n..ai/topic ;# export existing
then replace some parts with the new patch, and reapplying:
$ git reset --hard ai/topic~$n
$ git am -3 -s 000*.txt
The full test suite is always run for 'maint' and 'master'
after patch application; for topic branches the tests are run
as time permits.
- Update "What's cooking" message to review the updates to
existing topics, newly added topics and graduated topics.
This step is helped with Meta/UWC script.
- Merge topics to 'next'. For each branch whose tip is not
merged to 'next', one of three things can happen:
- The commits are all next-worthy; merge the topic to next:
$ git checkout next
$ git merge ai/topic ;# or "git merge ai/maint-topic"
$ make test
- The new parts are of mixed quality, but earlier ones are
next-worthy; merge the early parts to next:
$ git checkout next
$ git merge ai/topic~2 ;# the tip two are dubious
$ make test
- Nothing is next-worthy; do not do anything.
- Rebase topics that do not have any commit in next yet. This
step is optional but sometimes is worth doing when an old
series that is not in next can take advantage of low-level
framework change that is merged to 'master' already.
$ git rebase master ai/topic
This step is helped with Meta/git-topic.perl script to
identify which topic is rebaseable. There also is a
pre-rebase hook to make sure that topics that are already in
'next' are not rebased beyond the merged commit.
- Rebuild "pu" to merge the tips of topics not in 'next'.
$ git checkout pu
$ git reset --hard next
$ git merge ai/topic ;# repeat for all remaining topics
$ make test
This step is helped with Meta/PU script
- Push four integration branches to a private repository at
k.org and run "make test" on all of them.
- Push four integration branches to /pub/scm/git/git.git at
k.org. This triggers its post-update hook which:
(1) runs "git pull" in $HOME/git-doc/ repository to pull
'master' just pushed out;
(2) runs "make doc" in $HOME/git-doc/, install the generated
documentation in staging areas, which are separate
repositories that have html and man branches checked
out.
(3) runs "git commit" in the staging areas, and run "git
push" back to /pub/scm/git/git.git/ to update the html
and man branches.
(4) installs generated documentation to /pub/software/scm/git/docs/
to be viewed from http://www.kernel.org/
- Fetch html and man branches back from k.org, and push four
integration branches and the two documentation branches to
repo.or.cz
Some observations to be made.
* Each topic is tested individually, and also together with
other topics cooking in 'next'. Until it matures, none part
of it is merged to 'master'.
* A topic already in 'next' can get fixes while still in
'next'. Such a topic will have many merges to 'next' (in
other words, "git log --first-parent next" will show many
"Merge ai/topic to next" for the same topic.
* An unobvious fix for 'maint' is cooked in 'next' and then
merged to 'master' to make extra sure it is Ok and then
merged to 'maint'.
* Even when 'next' becomes empty (in other words, all topics
prove stable and are merged to 'master' and "git diff master
next" shows empty), it has tons of merge commits that will
never be in 'master'.
* In principle, "git log --first-parent master..next" should
show nothing but merges (in practice, there are fixup commits
and reverts that are not merges).
* Commits near the tip of a topic branch that are not in 'next'
are fair game to be discarded, replaced or rewritten.
Commits already merged to 'next' will not be.
* Being in the 'next' branch is not a guarantee for a topic to
be included in the next feature release. Being in the
'master' branch typically is.
^ permalink raw reply
* [PATCH] Fix segmentation fault when user doesn't have access permission to the repository.
From: André Goddard Rosa @ 2007-11-22 0:59 UTC (permalink / raw)
To: gitster; +Cc: Git Mailing List
[-- Attachment #1: Type: text/plain, Size: 3120 bytes --]
Hi, all!
Please cc: me as I'm not subscribed. I'm sending the patch inline
only for review, probably it is mangled.
Please use the attached patch if you agree with it. Sorry about
sending it attached.
>From b2af9e783e7d8974b969c01f7a2de07b9cd5cf70 Mon Sep 17 00:00:00 2001
From: Andre Goddard Rosa <andre.goddard@gmail.com>
Date: Tue, 27 Nov 2007 10:14:57 -0200
Subject: [PATCH] Fix segmentation fault when user doesn't have access
permission to the repository.
When trying to "git-pull" with my personal user in a tree owned by root,
git was crashing with segmentation fault.
Signed-off-by: Andre Goddard Rosa <andre.goddard@gmail.com>
---
builtin-fetch--tool.c | 12 ++++++++++--
builtin-fetch.c | 14 +++++++++++---
2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/builtin-fetch--tool.c b/builtin-fetch--tool.c
index ed60847..7460ab7 100644
--- a/builtin-fetch--tool.c
+++ b/builtin-fetch--tool.c
@@ -511,10 +511,14 @@ int cmd_fetch__tool(int argc, const char **argv,
const char *prefix)
if (!strcmp("append-fetch-head", argv[1])) {
int result;
FILE *fp;
+ char *filename;
if (argc != 8)
return error("append-fetch-head takes 6 args");
- fp = fopen(git_path("FETCH_HEAD"), "a");
+ filename = git_path("FETCH_HEAD");
+ fp = fopen(filename, "a");
+ if (!fp)
+ return error("cannot open %s: %s\n", filename, strerror(errno));
result = append_fetch_head(fp, argv[2], argv[3],
argv[4], argv[5],
argv[6], !!argv[7][0],
@@ -525,10 +529,14 @@ int cmd_fetch__tool(int argc, const char **argv,
const char *prefix)
if (!strcmp("native-store", argv[1])) {
int result;
FILE *fp;
+ char *filename;
if (argc != 5)
return error("fetch-native-store takes 3 args");
- fp = fopen(git_path("FETCH_HEAD"), "a");
+ filename = git_path("FETCH_HEAD");
+ fp = fopen(filename, "a");
+ if (!fp)
+ return error("cannot open %s: %s\n", filename, strerror(errno));
result = fetch_native_store(fp, argv[2], argv[3], argv[4],
verbose, force);
fclose(fp);
diff --git a/builtin-fetch.c b/builtin-fetch.c
index be9e3ea..5909d2f 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -263,8 +263,11 @@ static void store_updated_refs(const char *url,
struct ref *ref_map)
char note[1024];
const char *what, *kind;
struct ref *rm;
+ char *filename = git_path("FETCH_HEAD");
- fp = fopen(git_path("FETCH_HEAD"), "a");
+ fp = fopen(filename, "a");
+ if (!fp)
+ return error("cannot open %s: %s\n", filename, strerror(errno));
for (rm = ref_map; rm; rm = rm->next) {
struct ref *ref = NULL;
@@ -487,8 +490,13 @@ static int do_fetch(struct transport *transport,
die("Don't know how to fetch from %s", transport->url);
/* if not appending, truncate FETCH_HEAD */
- if (!append)
- fclose(fopen(git_path("FETCH_HEAD"), "w"));
+ if (!append) {
+ char *filename = git_path("FETCH_HEAD");
+ int fd = fopen(filename, "w");
+ if (!fd)
+ return error("cannot open %s: %s\n", filename, strerror(errno));
+ fclose(fd);
+ }
ref_map = get_ref_map(transport, refs, ref_count, tags, &autotags);
--
1.5.3.6.861.gd794-dirty
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-segmentation-fault-when-user-doesn-t-have-access.patch --]
[-- Type: text/x-patch; name=0001-Fix-segmentation-fault-when-user-doesn-t-have-access.patch, Size: 2916 bytes --]
From b2af9e783e7d8974b969c01f7a2de07b9cd5cf70 Mon Sep 17 00:00:00 2001
From: Andre Goddard Rosa <andre.goddard@gmail.com>
Date: Tue, 27 Nov 2007 10:14:57 -0200
Subject: [PATCH] Fix segmentation fault when user doesn't have access permission to the repository.
When trying to "git-pull" with my personal user in a tree owned by root,
git was crashing with segmentation fault.
Signed-off-by: Andre Goddard Rosa <andre.goddard@gmail.com>
---
builtin-fetch--tool.c | 12 ++++++++++--
builtin-fetch.c | 14 +++++++++++---
2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/builtin-fetch--tool.c b/builtin-fetch--tool.c
index ed60847..7460ab7 100644
--- a/builtin-fetch--tool.c
+++ b/builtin-fetch--tool.c
@@ -511,10 +511,14 @@ int cmd_fetch__tool(int argc, const char **argv, const char *prefix)
if (!strcmp("append-fetch-head", argv[1])) {
int result;
FILE *fp;
+ char *filename;
if (argc != 8)
return error("append-fetch-head takes 6 args");
- fp = fopen(git_path("FETCH_HEAD"), "a");
+ filename = git_path("FETCH_HEAD");
+ fp = fopen(filename, "a");
+ if (!fp)
+ return error("cannot open %s: %s\n", filename, strerror(errno));
result = append_fetch_head(fp, argv[2], argv[3],
argv[4], argv[5],
argv[6], !!argv[7][0],
@@ -525,10 +529,14 @@ int cmd_fetch__tool(int argc, const char **argv, const char *prefix)
if (!strcmp("native-store", argv[1])) {
int result;
FILE *fp;
+ char *filename;
if (argc != 5)
return error("fetch-native-store takes 3 args");
- fp = fopen(git_path("FETCH_HEAD"), "a");
+ filename = git_path("FETCH_HEAD");
+ fp = fopen(filename, "a");
+ if (!fp)
+ return error("cannot open %s: %s\n", filename, strerror(errno));
result = fetch_native_store(fp, argv[2], argv[3], argv[4],
verbose, force);
fclose(fp);
diff --git a/builtin-fetch.c b/builtin-fetch.c
index be9e3ea..5909d2f 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -263,8 +263,11 @@ static void store_updated_refs(const char *url, struct ref *ref_map)
char note[1024];
const char *what, *kind;
struct ref *rm;
+ char *filename = git_path("FETCH_HEAD");
- fp = fopen(git_path("FETCH_HEAD"), "a");
+ fp = fopen(filename, "a");
+ if (!fp)
+ return error("cannot open %s: %s\n", filename, strerror(errno));
for (rm = ref_map; rm; rm = rm->next) {
struct ref *ref = NULL;
@@ -487,8 +490,13 @@ static int do_fetch(struct transport *transport,
die("Don't know how to fetch from %s", transport->url);
/* if not appending, truncate FETCH_HEAD */
- if (!append)
- fclose(fopen(git_path("FETCH_HEAD"), "w"));
+ if (!append) {
+ char *filename = git_path("FETCH_HEAD");
+ int fd = fopen(filename, "w");
+ if (!fd)
+ return error("cannot open %s: %s\n", filename, strerror(errno));
+ fclose(fd);
+ }
ref_map = get_ref_map(transport, refs, ref_count, tags, &autotags);
--
1.5.3.6.861.gd794-dirty
^ permalink raw reply related
* [PATCH] For the sake of correctness, fix file descriptor leak.
From: André Goddard Rosa @ 2007-11-22 0:59 UTC (permalink / raw)
To: gitster; +Cc: Git Mailing List
[-- Attachment #1: Type: text/plain, Size: 1131 bytes --]
Hi, all!
Please cc: me as I'm not subscribed. I'm sending the patch inline
only for review, probably it is mangled.
Please use the attached patch if you agree with it. Sorry about
sending it attached.
>From 9fba346aca7470633ee46848013051248493896c Mon Sep 17 00:00:00 2001
From: Andre Goddard Rosa <andre.goddard@gmail.com>
Date: Tue, 27 Nov 2007 10:16:22 -0200
Subject: [PATCH] For the sake of correctness, fix file descriptor leak.
Signed-off-by: Andre Goddard Rosa <andre.goddard@gmail.com>
---
builtin-rerere.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/builtin-rerere.c b/builtin-rerere.c
index 7449323..31766be 100644
--- a/builtin-rerere.c
+++ b/builtin-rerere.c
@@ -275,8 +275,10 @@ static int copy_file(const char *src, const char *dest)
if (!(in = fopen(src, "r")))
return error("Could not open %s", src);
- if (!(out = fopen(dest, "w")))
+ if (!(out = fopen(dest, "w"))) {
+ fclose(in);
return error("Could not open %s", dest);
+ }
while ((count = fread(buffer, 1, sizeof(buffer), in)))
fwrite(buffer, 1, count, out);
fclose(in);
--
1.5.3.6.861.gd794-dirty
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-For-the-sake-of-correctness-fix-file-descriptor-le.patch --]
[-- Type: text/x-patch; name=0002-For-the-sake-of-correctness-fix-file-descriptor-le.patch, Size: 921 bytes --]
From 9fba346aca7470633ee46848013051248493896c Mon Sep 17 00:00:00 2001
From: Andre Goddard Rosa <andre.goddard@gmail.com>
Date: Tue, 27 Nov 2007 10:16:22 -0200
Subject: [PATCH] For the sake of correctness, fix file descriptor leak.
Signed-off-by: Andre Goddard Rosa <andre.goddard@gmail.com>
---
builtin-rerere.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/builtin-rerere.c b/builtin-rerere.c
index 7449323..31766be 100644
--- a/builtin-rerere.c
+++ b/builtin-rerere.c
@@ -275,8 +275,10 @@ static int copy_file(const char *src, const char *dest)
if (!(in = fopen(src, "r")))
return error("Could not open %s", src);
- if (!(out = fopen(dest, "w")))
+ if (!(out = fopen(dest, "w"))) {
+ fclose(in);
return error("Could not open %s", dest);
+ }
while ((count = fread(buffer, 1, sizeof(buffer), in)))
fwrite(buffer, 1, count, out);
fclose(in);
--
1.5.3.6.861.gd794-dirty
^ permalink raw reply related
* [PATCH] Avoid recalculating filename string pointer.
From: André Goddard Rosa @ 2007-11-22 0:59 UTC (permalink / raw)
To: gitster; +Cc: Git Mailing List
[-- Attachment #1: Type: text/plain, Size: 1288 bytes --]
Hi, all!
Please cc: me as I'm not subscribed. I'm sending the patch inline
only for review, probably it is mangled.
Please use the attached patch if you agree with it. Sorry about
sending it attached.
>From b6b05d9f8d8e053df4e971cd229e03b778c4d163 Mon Sep 17 00:00:00 2001
From: Andre Goddard Rosa <andre.goddard@gmail.com>
Date: Tue, 27 Nov 2007 10:17:54 -0200
Subject: [PATCH] Avoid recalculating filename string pointer.
Signed-off-by: Andre Goddard Rosa <andre.goddard@gmail.com>
---
fast-import.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/fast-import.c b/fast-import.c
index 98c2bd5..2d262eb 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -2304,11 +2304,13 @@ int main(int argc, const char **argv)
else if (!prefixcmp(a, "--export-marks="))
mark_file = a + 15;
else if (!prefixcmp(a, "--export-pack-edges=")) {
+ char *filename = a + 20;
+
if (pack_edges)
fclose(pack_edges);
- pack_edges = fopen(a + 20, "a");
+ pack_edges = fopen(filename, "a");
if (!pack_edges)
- die("Cannot open %s: %s", a + 20, strerror(errno));
+ die("Cannot open %s: %s", filename, strerror(errno));
} else if (!strcmp(a, "--force"))
force_update = 1;
else if (!strcmp(a, "--quiet"))
--
1.5.3.6.861.gd794-dirty
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0003-Avoid-recalculating-filename-string-pointer.patch --]
[-- Type: text/x-patch; name=0003-Avoid-recalculating-filename-string-pointer.patch, Size: 1077 bytes --]
From b6b05d9f8d8e053df4e971cd229e03b778c4d163 Mon Sep 17 00:00:00 2001
From: Andre Goddard Rosa <andre.goddard@gmail.com>
Date: Tue, 27 Nov 2007 10:17:54 -0200
Subject: [PATCH] Avoid recalculating filename string pointer.
Signed-off-by: Andre Goddard Rosa <andre.goddard@gmail.com>
---
fast-import.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/fast-import.c b/fast-import.c
index 98c2bd5..2d262eb 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -2304,11 +2304,13 @@ int main(int argc, const char **argv)
else if (!prefixcmp(a, "--export-marks="))
mark_file = a + 15;
else if (!prefixcmp(a, "--export-pack-edges=")) {
+ char *filename = a + 20;
+
if (pack_edges)
fclose(pack_edges);
- pack_edges = fopen(a + 20, "a");
+ pack_edges = fopen(filename, "a");
if (!pack_edges)
- die("Cannot open %s: %s", a + 20, strerror(errno));
+ die("Cannot open %s: %s", filename, strerror(errno));
} else if (!strcmp(a, "--force"))
force_update = 1;
else if (!strcmp(a, "--quiet"))
--
1.5.3.6.861.gd794-dirty
^ permalink raw reply related
* [PATCH] Simplify the code and avoid an attribution.
From: André Goddard Rosa @ 2007-11-22 1:00 UTC (permalink / raw)
To: gitster; +Cc: Git Mailing List
[-- Attachment #1: Type: text/plain, Size: 2119 bytes --]
Hi, all!
Please cc: me as I'm not subscribed. I'm sending the patch inline
only for review, probably it is mangled.
Please use the attached patch if you agree with it. Sorry about
sending it attached.
>From cd0cc6995684e2801011910735146052e5b59ccc Mon Sep 17 00:00:00 2001
From: Andre Goddard Rosa <andre.goddard@gmail.com>
Date: Tue, 27 Nov 2007 10:22:46 -0200
Subject: [PATCH] Simplify the code and avoid an attribution.
Signed-off-by: Andre Goddard Rosa <andre.goddard@gmail.com>
---
config.c | 19 ++++++++++---------
mailmap.c | 2 +-
xdiff-interface.c | 2 +-
3 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/config.c b/config.c
index 56e99fc..7c9fcdd 100644
--- a/config.c
+++ b/config.c
@@ -447,15 +447,16 @@ int git_config_from_file(config_fn_t fn, const
char *filename)
int ret;
FILE *f = fopen(filename, "r");
- ret = -1;
- if (f) {
- config_file = f;
- config_file_name = filename;
- config_linenr = 1;
- ret = git_parse_file(fn);
- fclose(f);
- config_file_name = NULL;
- }
+ if (!f)
+ return -1;
+
+ config_file = f;
+ config_file_name = filename;
+ config_linenr = 1;
+ ret = git_parse_file(fn);
+ fclose(f);
+ config_file_name = NULL;
+
return ret;
}
diff --git a/mailmap.c b/mailmap.c
index 8714167..0c13ecd 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -7,7 +7,7 @@ int read_mailmap(struct path_list *map, const char
*filename, char **repo_abbrev
char buffer[1024];
FILE *f = fopen(filename, "r");
- if (f == NULL)
+ if (!f)
return 1;
while (fgets(buffer, sizeof(buffer), f) != NULL) {
char *end_of_name, *left_bracket, *right_bracket;
diff --git a/xdiff-interface.c b/xdiff-interface.c
index be866d1..9dd1f3b 100644
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
@@ -111,7 +111,7 @@ int read_mmfile(mmfile_t *ptr, const char *filename)
if (stat(filename, &st))
return error("Could not stat %s", filename);
- if ((f = fopen(filename, "rb")) == NULL)
+ if (!(f = fopen(filename, "rb")))
return error("Could not open %s", filename);
sz = xsize_t(st.st_size);
ptr->ptr = xmalloc(sz);
--
1.5.3.6.861.gd794-dirty
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0004-Simplify-the-code-and-avoid-an-attribution.patch --]
[-- Type: text/x-patch; name=0004-Simplify-the-code-and-avoid-an-attribution.patch, Size: 1912 bytes --]
From cd0cc6995684e2801011910735146052e5b59ccc Mon Sep 17 00:00:00 2001
From: Andre Goddard Rosa <andre.goddard@gmail.com>
Date: Tue, 27 Nov 2007 10:22:46 -0200
Subject: [PATCH] Simplify the code and avoid an attribution.
Signed-off-by: Andre Goddard Rosa <andre.goddard@gmail.com>
---
config.c | 19 ++++++++++---------
mailmap.c | 2 +-
xdiff-interface.c | 2 +-
3 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/config.c b/config.c
index 56e99fc..7c9fcdd 100644
--- a/config.c
+++ b/config.c
@@ -447,15 +447,16 @@ int git_config_from_file(config_fn_t fn, const char *filename)
int ret;
FILE *f = fopen(filename, "r");
- ret = -1;
- if (f) {
- config_file = f;
- config_file_name = filename;
- config_linenr = 1;
- ret = git_parse_file(fn);
- fclose(f);
- config_file_name = NULL;
- }
+ if (!f)
+ return -1;
+
+ config_file = f;
+ config_file_name = filename;
+ config_linenr = 1;
+ ret = git_parse_file(fn);
+ fclose(f);
+ config_file_name = NULL;
+
return ret;
}
diff --git a/mailmap.c b/mailmap.c
index 8714167..0c13ecd 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -7,7 +7,7 @@ int read_mailmap(struct path_list *map, const char *filename, char **repo_abbrev
char buffer[1024];
FILE *f = fopen(filename, "r");
- if (f == NULL)
+ if (!f)
return 1;
while (fgets(buffer, sizeof(buffer), f) != NULL) {
char *end_of_name, *left_bracket, *right_bracket;
diff --git a/xdiff-interface.c b/xdiff-interface.c
index be866d1..9dd1f3b 100644
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
@@ -111,7 +111,7 @@ int read_mmfile(mmfile_t *ptr, const char *filename)
if (stat(filename, &st))
return error("Could not stat %s", filename);
- if ((f = fopen(filename, "rb")) == NULL)
+ if (!(f = fopen(filename, "rb")))
return error("Could not open %s", filename);
sz = xsize_t(st.st_size);
ptr->ptr = xmalloc(sz);
--
1.5.3.6.861.gd794-dirty
^ permalink raw reply related
* [PATCH] Print the real filename whose opening failed.
From: André Goddard Rosa @ 2007-11-22 1:00 UTC (permalink / raw)
To: gitster; +Cc: Git Mailing List
[-- Attachment #1: Type: text/plain, Size: 2637 bytes --]
Hi, all!
Please cc: me as I'm not subscribed. I'm sending the patch inline
only for review, probably it is mangled.
Please use the attached patch if you agree with it. Sorry about
sending it attached.
From 88b7bd873b97bd81e854827c9cd8f3c306d3c3af Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Andr=C3=A9=20Goddard=20Rosa?= <andre.goddard@gmail.com>
Date: Wed, 21 Nov 2007 18:59:14 -0200
Subject: [PATCH] Print the real filename whose opening failed.
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
---
http-push.c | 4 ++--
http-walker.c | 4 ++--
server-info.c | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/http-push.c b/http-push.c
index 9314621..e675ca6 100644
--- a/http-push.c
+++ b/http-push.c
@@ -433,7 +433,7 @@ static void start_fetch_packed(struct
transfer_request *request)
packfile = fopen(request->tmpfile, "a");
if (!packfile) {
fprintf(stderr, "Unable to open local file %s for pack",
- filename);
+ request->tmpfile);
remote->can_update_info_refs = 0;
free(url);
return;
@@ -941,7 +941,7 @@ static int fetch_index(unsigned char *sha1)
indexfile = fopen(tmpfile, "a");
if (!indexfile)
return error("Unable to open local file %s for pack index",
- filename);
+ tmpfile);
slot = get_active_slot();
slot->results = &results;
diff --git a/http-walker.c b/http-walker.c
index 444aebf..a3fb596 100644
--- a/http-walker.c
+++ b/http-walker.c
@@ -405,7 +405,7 @@ static int fetch_index(struct walker *walker,
struct alt_base *repo, unsigned ch
indexfile = fopen(tmpfile, "a");
if (!indexfile)
return error("Unable to open local file %s for pack index",
- filename);
+ tmpfile);
slot = get_active_slot();
slot->results = &results;
@@ -770,7 +770,7 @@ static int fetch_pack(struct walker *walker,
struct alt_base *repo, unsigned cha
packfile = fopen(tmpfile, "a");
if (!packfile)
return error("Unable to open local file %s for pack",
- filename);
+ tmpfile);
slot = get_active_slot();
slot->results = &results;
diff --git a/server-info.c b/server-info.c
index 0d1312c..a051e49 100644
--- a/server-info.c
+++ b/server-info.c
@@ -35,7 +35,7 @@ static int update_info_refs(int force)
safe_create_leading_directories(path0);
info_ref_fp = fopen(path1, "w");
if (!info_ref_fp)
- return error("unable to update %s", path0);
+ return error("unable to update %s", path1);
for_each_ref(add_info_ref, NULL);
fclose(info_ref_fp);
adjust_shared_perm(path1);
--
1.5.3.6.861.gd794-dirty
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0005-Print-the-real-filename-whose-opening-failed.patch --]
[-- Type: text/x-patch; name=0005-Print-the-real-filename-whose-opening-failed.patch, Size: 2430 bytes --]
From 88b7bd873b97bd81e854827c9cd8f3c306d3c3af Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Andr=C3=A9=20Goddard=20Rosa?= <andre.goddard@gmail.com>
Date: Wed, 21 Nov 2007 18:59:14 -0200
Subject: [PATCH] Print the real filename whose opening failed.
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
---
http-push.c | 4 ++--
http-walker.c | 4 ++--
server-info.c | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/http-push.c b/http-push.c
index 9314621..e675ca6 100644
--- a/http-push.c
+++ b/http-push.c
@@ -433,7 +433,7 @@ static void start_fetch_packed(struct transfer_request *request)
packfile = fopen(request->tmpfile, "a");
if (!packfile) {
fprintf(stderr, "Unable to open local file %s for pack",
- filename);
+ request->tmpfile);
remote->can_update_info_refs = 0;
free(url);
return;
@@ -941,7 +941,7 @@ static int fetch_index(unsigned char *sha1)
indexfile = fopen(tmpfile, "a");
if (!indexfile)
return error("Unable to open local file %s for pack index",
- filename);
+ tmpfile);
slot = get_active_slot();
slot->results = &results;
diff --git a/http-walker.c b/http-walker.c
index 444aebf..a3fb596 100644
--- a/http-walker.c
+++ b/http-walker.c
@@ -405,7 +405,7 @@ static int fetch_index(struct walker *walker, struct alt_base *repo, unsigned ch
indexfile = fopen(tmpfile, "a");
if (!indexfile)
return error("Unable to open local file %s for pack index",
- filename);
+ tmpfile);
slot = get_active_slot();
slot->results = &results;
@@ -770,7 +770,7 @@ static int fetch_pack(struct walker *walker, struct alt_base *repo, unsigned cha
packfile = fopen(tmpfile, "a");
if (!packfile)
return error("Unable to open local file %s for pack",
- filename);
+ tmpfile);
slot = get_active_slot();
slot->results = &results;
diff --git a/server-info.c b/server-info.c
index 0d1312c..a051e49 100644
--- a/server-info.c
+++ b/server-info.c
@@ -35,7 +35,7 @@ static int update_info_refs(int force)
safe_create_leading_directories(path0);
info_ref_fp = fopen(path1, "w");
if (!info_ref_fp)
- return error("unable to update %s", path0);
+ return error("unable to update %s", path1);
for_each_ref(add_info_ref, NULL);
fclose(info_ref_fp);
adjust_shared_perm(path1);
--
1.5.3.6.861.gd794-dirty
^ permalink raw reply related
* Re: [PATCH 1/3 v3] git-svn: extract reusable code into utility functions
From: Eric Wong @ 2007-11-22 1:19 UTC (permalink / raw)
To: David D. Kilzer; +Cc: git
In-Reply-To: <1195675039-26746-2-git-send-email-ddkilzer@kilzer.net>
"David D. Kilzer" <ddkilzer@kilzer.net> wrote:
> Extacted canonicalize_path() in the main package.
>
> Created new Git::SVN::Util package with an md5sum() function. A
> new package was created so that Digest::MD5 did not have to be
> loaded in the main package. Replaced code in the SVN::Git::Editor
> and SVN::Git::Fetcher packages with calls to md5sum().
>
> Extracted the format_svn_date(), parse_git_date() and
> set_local_timezone() functions within the Git::SVN::Log package.
>
> Signed-off-by: David D. Kilzer <ddkilzer@kilzer.net>
Thanks, this patch is independently useful.
Acked-by: Eric Wong <normalperson@yhbt.net>
I'm having a problem with [2/3] currently:
$file_type not being detected correctly when running "git svn info"
on the top-level directory with no arguments. It's opening the
directory and trying to md5 it here:
} else {
open FILE, "<", $path or die $!;
$checksum = Git::SVN::Util::md5sum(\*FILE);
close FILE or die $!;
}
> ---
> git-svn.perl | 96 ++++++++++++++++++++++++++++++++++++++-------------------
> 1 files changed, 64 insertions(+), 32 deletions(-)
>
> diff --git a/git-svn.perl b/git-svn.perl
> index 5b1deea..98c980f 100755
> --- a/git-svn.perl
> +++ b/git-svn.perl
> @@ -48,7 +48,8 @@ BEGIN {
> foreach (qw/command command_oneline command_noisy command_output_pipe
> command_input_pipe command_close_pipe/) {
> for my $package ( qw(SVN::Git::Editor SVN::Git::Fetcher
> - Git::SVN::Migration Git::SVN::Log Git::SVN),
> + Git::SVN::Migration Git::SVN::Log Git::SVN
> + Git::SVN::Util),
> __PACKAGE__) {
> *{"${package}::$_"} = \&{"Git::$_"};
> }
> @@ -583,6 +584,17 @@ sub cmd_create_ignore {
> });
> }
>
> +sub canonicalize_path {
> + my ($path) = @_;
> + # File::Spec->canonpath doesn't collapse x/../y into y (for a
> + # good reason), so let's do this manually.
> + $path =~ s#/+#/#g;
> + $path =~ s#/\.(?:/|$)#/#g;
> + $path =~ s#/[^/]+/\.\.##g;
> + $path =~ s#/$##g;
> + return $path;
> +}
> +
> # get_svnprops(PATH)
> # ------------------
> # Helper for cmd_propget and cmd_proplist below.
> @@ -600,12 +612,7 @@ sub get_svnprops {
>
> # canonicalize the path (otherwise libsvn will abort or fail to
> # find the file)
> - # File::Spec->canonpath doesn't collapse x/../y into y (for a
> - # good reason), so let's do this manually.
> - $path =~ s#/+#/#g;
> - $path =~ s#/\.(?:/|$)#/#g;
> - $path =~ s#/[^/]+/\.\.##g;
> - $path =~ s#/$##g;
> + $path = canonicalize_path($path);
>
> my $r = (defined $_revision ? $_revision : $gs->ra->get_latest_revnum);
> my $props;
> @@ -1043,6 +1050,27 @@ sub linearize_history {
> (\@linear_refs, \%parents);
> }
>
> +package Git::SVN::Util;
> +use strict;
> +use warnings;
> +use Digest::MD5;
> +
> +sub md5sum {
> + my $arg = shift;
> + my $ref = ref $arg;
> + my $md5 = Digest::MD5->new();
> + if ($ref eq 'GLOB' || $ref eq 'IO::File') {
> + $md5->addfile($arg) or croak $!;
> + } elsif ($ref eq 'SCALAR') {
> + $md5->add($$arg) or croak $!;
> + } elsif (!$ref) {
> + $md5->add($arg) or croak $!;
> + } else {
> + ::fatal "Can't provide MD5 hash for unknown ref type: '", $ref, "'";
> + }
> + return $md5->hexdigest();
> +}
> +
> package Git::SVN;
> use strict;
> use warnings;
> @@ -2610,7 +2638,6 @@ use strict;
> use warnings;
> use Carp qw/croak/;
> use IO::File qw//;
> -use Digest::MD5;
>
> # file baton members: path, mode_a, mode_b, pool, fh, blob, base
> sub new {
> @@ -2762,9 +2789,7 @@ sub apply_textdelta {
>
> if (defined $exp) {
> seek $base, 0, 0 or croak $!;
> - my $md5 = Digest::MD5->new;
> - $md5->addfile($base);
> - my $got = $md5->hexdigest;
> + my $got = Git::SVN::Util::md5sum($base);
> die "Checksum mismatch: $fb->{path} $fb->{blob}\n",
> "expected: $exp\n",
> " got: $got\n" if ($got ne $exp);
> @@ -2783,9 +2808,7 @@ sub close_file {
> if (my $fh = $fb->{fh}) {
> if (defined $exp) {
> seek($fh, 0, 0) or croak $!;
> - my $md5 = Digest::MD5->new;
> - $md5->addfile($fh);
> - my $got = $md5->hexdigest;
> + my $got = Git::SVN::Util::md5sum($fh);
> if ($got ne $exp) {
> die "Checksum mismatch: $path\n",
> "expected: $exp\n got: $got\n";
> @@ -2837,7 +2860,6 @@ use strict;
> use warnings;
> use Carp qw/croak/;
> use IO::File;
> -use Digest::MD5;
>
> sub new {
> my ($class, $opts) = @_;
> @@ -3141,11 +3163,9 @@ sub chg_file {
> $fh->flush == 0 or croak $!;
> seek $fh, 0, 0 or croak $!;
>
> - my $md5 = Digest::MD5->new;
> - $md5->addfile($fh) or croak $!;
> + my $exp = Git::SVN::Util::md5sum($fh);
> seek $fh, 0, 0 or croak $!;
>
> - my $exp = $md5->hexdigest;
> my $pool = SVN::Pool->new;
> my $atd = $self->apply_textdelta($fbat, undef, $pool);
> my $got = SVN::TxDelta::send_stream($fh, @$atd, $pool);
> @@ -3859,6 +3879,29 @@ sub run_pager {
> exec $pager or ::fatal "Can't run pager: $! ($pager)";
> }
>
> +sub format_svn_date {
> + return strftime("%Y-%m-%d %H:%M:%S %z (%a, %d %b %Y)", localtime(shift));
> +}
> +
> +sub parse_git_date {
> + my ($t, $tz) = @_;
> + # Date::Parse isn't in the standard Perl distro :(
> + if ($tz =~ s/^\+//) {
> + $t += tz_to_s_offset($tz);
> + } elsif ($tz =~ s/^\-//) {
> + $t -= tz_to_s_offset($tz);
> + }
> + return $t;
> +}
> +
> +sub set_local_timezone {
> + if (defined $TZ) {
> + $ENV{TZ} = $TZ;
> + } else {
> + delete $ENV{TZ};
> + }
> +}
> +
> sub tz_to_s_offset {
> my ($tz) = @_;
> $tz =~ s/(\d\d)$//;
> @@ -3879,13 +3922,7 @@ sub get_author_info {
> $dest->{t} = $t;
> $dest->{tz} = $tz;
> $dest->{a} = $au;
> - # Date::Parse isn't in the standard Perl distro :(
> - if ($tz =~ s/^\+//) {
> - $t += tz_to_s_offset($tz);
> - } elsif ($tz =~ s/^\-//) {
> - $t -= tz_to_s_offset($tz);
> - }
> - $dest->{t_utc} = $t;
> + $dest->{t_utc} = parse_git_date($t, $tz);
> }
>
> sub process_commit {
> @@ -3939,8 +3976,7 @@ sub show_commit_normal {
> my ($c) = @_;
> print commit_log_separator, "r$c->{r} | ";
> print "$c->{c} | " if $show_commit;
> - print "$c->{a} | ", strftime("%Y-%m-%d %H:%M:%S %z (%a, %d %b %Y)",
> - localtime($c->{t_utc})), ' | ';
> + print "$c->{a} | ", format_svn_date($c->{t_utc}), ' | ';
> my $nr_line = 0;
>
> if (my $l = $c->{l}) {
> @@ -3980,11 +4016,7 @@ sub cmd_show_log {
> my (@args) = @_;
> my ($r_min, $r_max);
> my $r_last = -1; # prevent dupes
> - if (defined $TZ) {
> - $ENV{TZ} = $TZ;
> - } else {
> - delete $ENV{TZ};
> - }
> + set_local_timezone();
> if (defined $::_revision) {
> if ($::_revision =~ /^(\d+):(\d+)$/) {
> ($r_min, $r_max) = ($1, $2);
--
Eric Wong
^ permalink raw reply
* Re: [PATCH 3/3] Replace setenv(GIT_DIR_ENVIRONMENT, ...) with set_git_dir()
From: Johannes Schindelin @ 2007-11-22 1:22 UTC (permalink / raw)
To: Steffen Prohaska; +Cc: git, Dmitry Kakurin
In-Reply-To: <11956768412755-git-send-email-prohaska@zib.de>
Hi,
On Wed, 21 Nov 2007, Steffen Prohaska wrote:
> We have a function set_git_dir(). So let's use it, instead of setting
> the evironment directly.
Does this not have a fundamental issue? When you call other git programs
with run_command(), you _need_ GIT_DIR to be set, no?
Ciao,
Dscho
^ permalink raw reply
* [PATCH] Add path-limiting to git-add--interactive
From: Wincent Colaiuta @ 2007-11-22 1:36 UTC (permalink / raw)
To: git; +Cc: gitster, peff, Wincent Colaiuta
In-Reply-To: <7vk5obb09a.fsf@gitster.siamese.dyndns.org>
Implement Junio's suggestion that git-add--interactive should reproduce the
path-limiting semantics of non-interactive git-add.
In otherwords, if "git add -i" (unrestricted) shows paths from a set A,
"git add -i paths..." should show paths from a subset of the set A and that
subset should be defined with the existing ls-files pathspec semantics.
Signed-off-by: Wincent Colaiuta <win@wincent.com>
---
git-add--interactive.perl | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 2bba07d..a5a07bc 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -37,7 +37,7 @@ sub list_untracked {
chomp $_;
$_;
}
- run_cmd_pipe(qw(git ls-files --others --exclude-standard --), @_);
+ run_cmd_pipe(qw(git ls-files --others --exclude-standard --), @ARGV);
}
my $status_fmt = '%12s %12s %s';
@@ -56,9 +56,14 @@ sub list_modified {
my ($only) = @_;
my (%data, @return);
my ($add, $del, $adddel, $file);
+ my @tracked = grep {
+ defined run_cmd_pipe(qw(git ls-files
+ --exclude-standard --), $_)
+ } @ARGV;
+ return if $#tracked == -1 && $#ARGV != -1;
for (run_cmd_pipe(qw(git diff-index --cached
- --numstat --summary HEAD))) {
+ --numstat --summary HEAD --), @tracked)) {
if (($add, $del, $file) =
/^([-\d]+) ([-\d]+) (.*)/) {
my ($change, $bin);
@@ -81,7 +86,7 @@ sub list_modified {
}
}
- for (run_cmd_pipe(qw(git diff-files --numstat --summary))) {
+ for (run_cmd_pipe(qw(git diff-files --numstat --summary --), @tracked)) {
if (($add, $del, $file) =
/^([-\d]+) ([-\d]+) (.*)/) {
if (!exists $data{$file}) {
--
1.5.3.6.870.g8799-dirty
^ permalink raw reply related
* Re: [PATCH 2/3 v3] git-svn info: implement info command
From: Eric Wong @ 2007-11-22 1:40 UTC (permalink / raw)
To: David D. Kilzer; +Cc: git
In-Reply-To: <1195675039-26746-3-git-send-email-ddkilzer@kilzer.net>
"David D. Kilzer" <ddkilzer@kilzer.net> wrote:
> Implement "git-svn info" for files and directories based on the
> "svn info" command. Note that the -r/--revision argument is not
> supported yet.
>
> Added 18 tests in t/t9119-git-svn-info.sh.
Eric Wong <normalperson@yhbt.net> wrote:
> I'm having a problem with [2/3] currently:
>
> $file_type not being detected correctly when running "git svn info"
> on the top-level directory with no arguments. It's opening the
> directory and trying to md5 it here:
>
> } else {
> open FILE, "<", $path or die $!;
> $checksum = Git::SVN::Util::md5sum(\*FILE);
> close FILE or die $!;
> }
>
>
When running from a top-level directory with no arguments, the first
line of git-ls-tree was being read. This allowed the test case to pass
because ls-tree sorts the output and 'directory' just happened to
be up top; so we were getting the 040000 mode from the 'directory'
tree and not the top-level tree.
The below test should fix it for the trivial case I have.
diff --git a/git-svn.perl b/git-svn.perl
index 62801c8..7d86870 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -1165,6 +1165,7 @@ sub linearize_history {
sub find_file_type_and_diff_status {
my ($path) = @_;
+ return ('dir', '') if $path eq '.';
my $diff_output =
command_oneline(qw(diff --cached --name-status --), $path) || "";
diff --git a/t/t9119-git-svn-info.sh b/t/t9119-git-svn-info.sh
index e81457f..439bd93 100644
--- a/t/t9119-git-svn-info.sh
+++ b/t/t9119-git-svn-info.sh
@@ -19,6 +19,7 @@ ptouch() {
test_expect_success 'setup repository and import' "
mkdir info &&
cd info &&
+ echo FIRST > A &&
echo one > file &&
ln -s file symlink-file &&
mkdir directory &&
--
Eric Wong
^ permalink raw reply related
* Re: [PATCH 2/4] Teach git-add--interactive to accept a file path to patch
From: Wincent Colaiuta @ 2007-11-22 1:41 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Jeff King, git
In-Reply-To: <7vk5obb09a.fsf@gitster.siamese.dyndns.org>
El 22/11/2007, a las 1:18, Junio C Hamano escribió:
> Wincent Colaiuta <win@wincent.com> writes:
>
>> - Junio, do you mean to suggest with your comment that when passing
>> untracked files either directly or indirectly (ie. when passing a dir
>> containing untracked files) that they should be added (ie. invoked
>> the
>> "add untracked" subcommand) in addition to running the "patch"
>> subcommand on the changed files?
>
> What I meant was that if "git add -i" (unrestricted) shows paths
> from a set A, "git add -i paths..." should show paths from a
> subset of the set A and that subset should be defined with the
> existing ls-files pathspec semantics.
>
> For example, if "(a)dd untracked" subcommand shows all untracked
> files when "add -i" was invoked without paths limitation, the
> restricted form "add -i paths..." would show only untracked paths
> that match the given set of patterns. If "(p)atch" subcommand
> shows all modified tracked files when "add -i" was invoked
> without paths limitation, the restricted form "add -i paths..."
> would show only such modified tracked files whose names match
> the given set of patterns.
Ok, I've just posted a patch that implements this. This is now going
somewhat beyond my knowledge of git-diff-index, git-diff-files, and
git-diff-ls, so I am hoping someone more familiar with the plumbing
can review this. Basically I'm mostly a porcelain user and have hardly
touched the plumbing at all during these initial months using Git.
There may be more efficient ways of doing this, but for now I am
running git-ls-files once for each path parameter to determine whether
it corresponds to any tracked file(s). This is necessary to weed out
the untracked paths because passing these to git-diff-index or git-
diff-files otherwise spits out errors to the stderr.
Cheers,
Wincent
^ permalink raw reply
* Re: Adding push configuration to .git/config
From: Junio C Hamano @ 2007-11-22 1:48 UTC (permalink / raw)
To: Nico -telmich- Schottelius; +Cc: git
In-Reply-To: <20071121105517.GA11875@denkbrett.schottelius.org>
Nico -telmich- Schottelius <nico-linux-git@schottelius.org>
writes:
> Nice would be
>
> [branch "master"]
> remote-push = origin
> remote-push-merge = another_branch
>
> And thus perhaps also changing the existing specs:
>
> remote = ... to remote-fetch = ...
> merge = ... to remote-fetch-merge =
I do not think doing this is worth it, not because I think a
single branch.$name.remote should be good enough for everybody,
but because once you need a separate remote each for fetching
and pushing, there is no reason to say one per direction is
enough.
An alternative could be to split [remote "name"] url into two
variants, fetch-url and push-url. While fetching by default
from two places without telling from which one does not make any
sense, pushing by default to two different places is quite a
normal thing to do, and we already do support more than one url
entries in [remote "name"] section used for pushing.
If we were to do this, it might also make sense to rename the
word 'origin' we use for the default remote name to 'default' or
something. People with shared repository workflow would fetch
from one repository and push back to the same repository, so the
distinction would not matter, but for others who need something
like you suggest, the default repository for fetching and
pushing are different, and while you may still consider where
you fetch from your 'origin', where you push into is not your
'origin' anymore.
^ permalink raw reply
* [PATCH v2] builtin-commit: Include the diff in the commit message when verbose.
From: Kristian Høgsberg @ 2007-11-22 2:54 UTC (permalink / raw)
To: gitster; +Cc: git, Kristian Høgsberg
run_diff_index() and the entire diff machinery is hard coded to output
to stdout, so just redirect that and restore it when done.
Signed-off-by: Kristian Høgsberg <krh@redhat.com>
---
Thinking about this, the dup-dance really belongs in wt-status.c since
that interface promises that it can redirect to a FILE *. Also the
fflush()'es in the earlier patch could go wrong if stdout ends up flushing
during run_diff_index() and fp has unflushed data.
builtin-commit.c | 8 +++++++-
wt-status.c | 16 ++++++++++++++++
2 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/builtin-commit.c b/builtin-commit.c
index e8893f8..39764ae 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -662,7 +662,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
int header_len;
struct strbuf sb;
const char *index_file, *reflog_msg;
- char *nl;
+ char *nl, *p;
unsigned char commit_sha1[20];
struct ref_lock *ref_lock;
@@ -758,6 +758,12 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
rollback_index_files();
exit(1);
}
+
+ /* Truncate the message just before the diff, if any. */
+ p = strstr(sb.buf, "\ndiff --git a/");
+ if (p != NULL)
+ strbuf_setlen(&sb, p - sb.buf);
+
stripspace(&sb, 1);
if (sb.len < header_len || message_is_empty(&sb, header_len)) {
rollback_index_files();
diff --git a/wt-status.c b/wt-status.c
index d3c10b8..0e0439f 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -315,12 +315,28 @@ static void wt_status_print_untracked(struct wt_status *s)
static void wt_status_print_verbose(struct wt_status *s)
{
struct rev_info rev;
+ int saved_stdout;
+
+ fflush(s->fp);
+
+ /* Sigh, the entire diff machinery is hardcoded to output to
+ * stdout. Do the dup-dance...*/
+ saved_stdout = dup(STDOUT_FILENO);
+ if (saved_stdout < 0 ||dup2(fileno(s->fp), STDOUT_FILENO) < 0)
+ die("couldn't redirect stdout\n");
+
init_revisions(&rev, NULL);
setup_revisions(0, NULL, &rev, s->reference);
rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
rev.diffopt.detect_rename = 1;
wt_read_cache(s);
run_diff_index(&rev, 1);
+
+ fflush(stdout);
+
+ if (dup2(saved_stdout, STDOUT_FILENO) < 0)
+ die("couldn't restore stdout\n");
+ close(saved_stdout);
}
void wt_status_print(struct wt_status *s)
--
1.5.3.4
^ permalink raw reply related
* [PATCH 4/3] git-svn: allow `info' command to work offline
From: Eric Wong @ 2007-11-22 2:23 UTC (permalink / raw)
To: David D. Kilzer; +Cc: git
In-Reply-To: <1195675039-26746-1-git-send-email-ddkilzer@kilzer.net>
Cache the repository root whenever we connect to the repository.
This will allow us to notice URL changes if the user changes the
URL in .git/config, too.
If the repository is no longer accessible, or if `git svn info'
is the first and only command run; then '(offline)' will be
displayed for "Repository Root:" in the output.
Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
David:
I'll apply this once you've verified my fix to 1/3 is correct behavior,
too.
git-svn.perl | 26 +++++++++++++++++++++++---
1 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index 7d86870..43e1591 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -782,9 +782,14 @@ sub cmd_info {
$result .= "Name: " . basename($path) . "\n" if $file_type ne "dir";
$result .= "URL: " . $full_url . "\n";
- my $repos_root = $gs->ra->{repos_root};
- Git::SVN::remove_username($repos_root);
- $result .= "Repository Root: $repos_root\n";
+ eval {
+ my $repos_root = $gs->repos_root;
+ Git::SVN::remove_username($repos_root);
+ $result .= "Repository Root: $repos_root\n";
+ };
+ if ($@) {
+ $result .= "Repository Root: (offline)\n";
+ }
$result .= "Repository UUID: $uuid\n" unless $diff_status eq "A";
$result .= "Revision: " . ($diff_status eq "A" ? 0 : $rev) . "\n";
@@ -1773,9 +1778,24 @@ sub ra_uuid {
$self->{ra_uuid};
}
+sub _set_repos_root {
+ my ($self, $repos_root) = @_;
+ my $k = "svn-remote.$self->{repo_id}.reposRoot";
+ $repos_root ||= $self->ra->{repos_root};
+ tmp_config($k, $repos_root);
+ $repos_root;
+}
+
+sub repos_root {
+ my ($self) = @_;
+ my $k = "svn-remote.$self->{repo_id}.reposRoot";
+ eval { tmp_config('--get', $k) } || $self->_set_repos_root;
+}
+
sub ra {
my ($self) = shift;
my $ra = Git::SVN::Ra->new($self->{url});
+ $self->_set_repos_root($ra->{repos_root});
if ($self->use_svm_props && !$self->{svm}) {
if ($self->no_metadata) {
die "Can't have both 'noMetadata' and ",
--
Eric Wong
^ permalink raw reply related
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