* Re: Numeric Revision Names?
From: Jeff King @ 2008-10-03 17:37 UTC (permalink / raw)
To: Stephen Haberman; +Cc: Jakub Narebski, marceloribeiro, git
In-Reply-To: <20081003171434.GC30592@coredump.intra.peff.net>
On Fri, Oct 03, 2008 at 01:14:34PM -0400, Jeff King wrote:
> If you are constraining yourself to a central repo, then you could just
> add a receive hook that tags each new commit with a monotonically
> increasing revision number. Clients would get the tags upon fetch.
Oh, nevermind. I'm an idiot and didn't bother reading to the end of your
post, where you clearly attached a hook that does exactly that.
Sorry for the noise.
-Peff
^ permalink raw reply
* [PATCH] gitweb: refactor input parameters parse/validation
From: Giuseppe Bilotta @ 2008-10-03 17:19 UTC (permalink / raw)
To: git; +Cc: Jakub Narebski, Shawn O. Pearce, Giuseppe Bilotta
Since input parameters can be obtained both from CGI parameters and
PATH_INFO, we would like most of the code to be agnostic about the way
parameters were retrieved. We thus collect all the parameters into the
new %input_params hash, delaying validation after the collection is
completed.
Although the kludge removal is minimal at the moment, it makes life much
easier for future expansions such as more extensive PATH_INFO use or
other form of input (e.g. command-line support).
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
As recommended by Jakub, I reworked the input parameter collection refactoring
into a separate patch preluding to rather than intermixed with the PATH_INFO
enhancement work.
gitweb/gitweb.perl | 304 +++++++++++++++++++++++++++++-----------------------
1 files changed, 171 insertions(+), 133 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 83f810a..329f789 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -29,7 +29,9 @@ our $my_uri = $cgi->url(-absolute => 1);
# if we're called with PATH_INFO, we have to strip that
# from the URL to find our real URL
-if (my $path_info = $ENV{"PATH_INFO"}) {
+# we make $path_info global because it's also used later on
+my $path_info = $ENV{"PATH_INFO"};
+if ($path_info) {
$my_url =~ s,\Q$path_info\E$,,;
$my_uri =~ s,\Q$path_info\E$,,;
}
@@ -390,34 +392,149 @@ $projects_list ||= $projectroot;
# ======================================================================
# input validation and dispatch
-our $action = $cgi->param('a');
+
+# input parameters can be collected from a variety of sources (presently, CGI
+# and PATH_INFO), so we define an %input_params hash that collects them all
+# together during validation: this allows subsequent uses (e.g. href()) to be
+# agnostic of the parameter origin
+
+my %input_params = ();
+
+# input parameters are stored with the long parameter name as key, so we need
+# the name -> CGI key mapping here. This will also be used in the href
+# subroutine to convert parameters to their CGI equivalent.
+#
+# XXX: Warning: If you touch this, check the search form for updating,
+# too.
+
+my @cgi_param_mapping = (
+ project => "p",
+ action => "a",
+ file_name => "f",
+ file_parent => "fp",
+ hash => "h",
+ hash_parent => "hp",
+ hash_base => "hb",
+ hash_parent_base => "hpb",
+ page => "pg",
+ order => "o",
+ searchtext => "s",
+ searchtype => "st",
+ snapshot_format => "sf",
+ extra_options => "opt",
+ search_use_regexp => "sr",
+);
+my %cgi_param_mapping = @cgi_param_mapping;
+
+# we will also need to know the possible actions, for validation
+my %actions = (
+ "blame" => \&git_blame,
+ "blobdiff" => \&git_blobdiff,
+ "blobdiff_plain" => \&git_blobdiff_plain,
+ "blob" => \&git_blob,
+ "blob_plain" => \&git_blob_plain,
+ "commitdiff" => \&git_commitdiff,
+ "commitdiff_plain" => \&git_commitdiff_plain,
+ "commit" => \&git_commit,
+ "forks" => \&git_forks,
+ "heads" => \&git_heads,
+ "history" => \&git_history,
+ "log" => \&git_log,
+ "rss" => \&git_rss,
+ "atom" => \&git_atom,
+ "search" => \&git_search,
+ "search_help" => \&git_search_help,
+ "shortlog" => \&git_shortlog,
+ "summary" => \&git_summary,
+ "tag" => \&git_tag,
+ "tags" => \&git_tags,
+ "tree" => \&git_tree,
+ "snapshot" => \&git_snapshot,
+ "object" => \&git_object,
+ # those below don't need $project
+ "opml" => \&git_opml,
+ "project_list" => \&git_project_list,
+ "project_index" => \&git_project_index,
+);
+
+# fill %input_params with the CGI parameters. All values except for 'opt'
+# should be single values, but opt can be an array. We should probably
+# build an array of parameters that can be multi-valued, but since for the time
+# being it's only this one, we just single it out
+while (my ($name, $symbol) = each %cgi_param_mapping) {
+ if ($symbol eq 'opt') {
+ $input_params{$name} = [$cgi->param($symbol)];
+ } else {
+ $input_params{$name} = $cgi->param($symbol);
+ }
+}
+
+# now read PATH_INFO and update the parameter list for missing parameters
+sub evaluate_path_info {
+ return if defined $input_params{'project'};
+ return if !$path_info;
+ $path_info =~ s,^/+,,;
+ return if !$path_info;
+
+ # find which part of PATH_INFO is project
+ my $project = $path_info;
+ $project =~ s,/+$,,;
+ while ($project && !check_head_link("$projectroot/$project")) {
+ $project =~ s,/*[^/]*$,,;
+ }
+ # validate project
+ $project = validate_project($project);
+ return unless $project;
+ $input_params{'project'} = $project;
+
+ # do not change any parameters if an action is given using the query string
+ return if $input_params{'action'};
+ $path_info =~ s,^\Q$project\E/*,,;
+ my ($refname, $pathname) = split(/:/, $path_info, 2);
+ if (defined $pathname) {
+ # we got "project.git/branch:filename" or "project.git/branch:dir/"
+ # we could use git_get_type(branch:pathname), but it needs $git_dir
+ $pathname =~ s,^/+,,;
+ if (!$pathname || substr($pathname, -1) eq "/") {
+ $input_params{'action'} = "tree";
+ $pathname =~ s,/$,,;
+ } else {
+ $input_params{'action'} = "blob_plain";
+ }
+ $input_params{'hash_base'} ||= validate_refname($refname);
+ $input_params{'file_name'} ||= validate_pathname($pathname);
+ } elsif (defined $refname) {
+ # we got "project.git/branch"
+ $input_params{'action'} = "shortlog";
+ $input_params{'hash'} ||= validate_refname($refname);
+ }
+}
+evaluate_path_info();
+
+our $action = $input_params{'action'};
if (defined $action) {
- if ($action =~ m/[^0-9a-zA-Z\.\-_]/) {
+ if (!validate_action($action)) {
die_error(400, "Invalid action parameter");
}
}
# parameters which are pathnames
-our $project = $cgi->param('p');
+our $project = $input_params{'project'};
if (defined $project) {
- if (!validate_pathname($project) ||
- !(-d "$projectroot/$project") ||
- !check_head_link("$projectroot/$project") ||
- ($export_ok && !(-e "$projectroot/$project/$export_ok")) ||
- ($strict_export && !project_in_list($project))) {
+ if (!validate_project($project)) {
undef $project;
die_error(404, "No such project");
}
}
-our $file_name = $cgi->param('f');
+our $file_name = $input_params{'file_name'};
if (defined $file_name) {
if (!validate_pathname($file_name)) {
die_error(400, "Invalid file parameter");
}
}
-our $file_parent = $cgi->param('fp');
+our $file_parent = $input_params{'file_parent'};
if (defined $file_parent) {
if (!validate_pathname($file_parent)) {
die_error(400, "Invalid file parent parameter");
@@ -425,21 +542,21 @@ if (defined $file_parent) {
}
# parameters which are refnames
-our $hash = $cgi->param('h');
+our $hash = $input_params{'hash'};
if (defined $hash) {
if (!validate_refname($hash)) {
die_error(400, "Invalid hash parameter");
}
}
-our $hash_parent = $cgi->param('hp');
+our $hash_parent = $input_params{'hash_parent'};
if (defined $hash_parent) {
if (!validate_refname($hash_parent)) {
die_error(400, "Invalid hash parent parameter");
}
}
-our $hash_base = $cgi->param('hb');
+our $hash_base = $input_params{'hash_base'};
if (defined $hash_base) {
if (!validate_refname($hash_base)) {
die_error(400, "Invalid hash base parameter");
@@ -450,19 +567,19 @@ my %allowed_options = (
"--no-merges" => [ qw(rss atom log shortlog history) ],
);
-our @extra_options = $cgi->param('opt');
-if (defined @extra_options) {
- foreach my $opt (@extra_options) {
- if (not exists $allowed_options{$opt}) {
- die_error(400, "Invalid option parameter");
- }
- if (not grep(/^$action$/, @{$allowed_options{$opt}})) {
- die_error(400, "Invalid option parameter for this action");
- }
+our @extra_options = @{$input_params{'extra_options'}};
+# @extra_options is always defined, since it can only be (currently) set from
+# CGI, and $cgi->param() returns the empty array in array context
+foreach my $opt (@extra_options) {
+ if (not exists $allowed_options{$opt}) {
+ die_error(400, "Invalid option parameter");
+ }
+ if (not grep(/^$action$/, @{$allowed_options{$opt}})) {
+ die_error(400, "Invalid option parameter for this action");
}
}
-our $hash_parent_base = $cgi->param('hpb');
+our $hash_parent_base = $input_params{'hash_parent_base'};
if (defined $hash_parent_base) {
if (!validate_refname($hash_parent_base)) {
die_error(400, "Invalid hash parent base parameter");
@@ -470,23 +587,23 @@ if (defined $hash_parent_base) {
}
# other parameters
-our $page = $cgi->param('pg');
+our $page = $input_params{'page'};
if (defined $page) {
if ($page =~ m/[^0-9]/) {
die_error(400, "Invalid page parameter");
}
}
-our $searchtype = $cgi->param('st');
+our $searchtype = $input_params{'searchtype'};
if (defined $searchtype) {
if ($searchtype =~ m/[^a-z]/) {
die_error(400, "Invalid searchtype parameter");
}
}
-our $search_use_regexp = $cgi->param('sr');
+our $search_use_regexp = $input_params{'search_use_regexp'};
-our $searchtext = $cgi->param('s');
+our $searchtext = $input_params{'searchtext'};
our $search_regexp;
if (defined $searchtext) {
if (length($searchtext) < 2) {
@@ -495,86 +612,11 @@ if (defined $searchtext) {
$search_regexp = $search_use_regexp ? $searchtext : quotemeta $searchtext;
}
-# now read PATH_INFO and use it as alternative to parameters
-sub evaluate_path_info {
- return if defined $project;
- my $path_info = $ENV{"PATH_INFO"};
- return if !$path_info;
- $path_info =~ s,^/+,,;
- return if !$path_info;
- # find which part of PATH_INFO is project
- $project = $path_info;
- $project =~ s,/+$,,;
- while ($project && !check_head_link("$projectroot/$project")) {
- $project =~ s,/*[^/]*$,,;
- }
- # validate project
- $project = validate_pathname($project);
- if (!$project ||
- ($export_ok && !-e "$projectroot/$project/$export_ok") ||
- ($strict_export && !project_in_list($project))) {
- undef $project;
- return;
- }
- # do not change any parameters if an action is given using the query string
- return if $action;
- $path_info =~ s,^\Q$project\E/*,,;
- my ($refname, $pathname) = split(/:/, $path_info, 2);
- if (defined $pathname) {
- # we got "project.git/branch:filename" or "project.git/branch:dir/"
- # we could use git_get_type(branch:pathname), but it needs $git_dir
- $pathname =~ s,^/+,,;
- if (!$pathname || substr($pathname, -1) eq "/") {
- $action ||= "tree";
- $pathname =~ s,/$,,;
- } else {
- $action ||= "blob_plain";
- }
- $hash_base ||= validate_refname($refname);
- $file_name ||= validate_pathname($pathname);
- } elsif (defined $refname) {
- # we got "project.git/branch"
- $action ||= "shortlog";
- $hash ||= validate_refname($refname);
- }
-}
-evaluate_path_info();
-
# path to the current git repository
our $git_dir;
$git_dir = "$projectroot/$project" if $project;
# dispatch
-my %actions = (
- "blame" => \&git_blame,
- "blobdiff" => \&git_blobdiff,
- "blobdiff_plain" => \&git_blobdiff_plain,
- "blob" => \&git_blob,
- "blob_plain" => \&git_blob_plain,
- "commitdiff" => \&git_commitdiff,
- "commitdiff_plain" => \&git_commitdiff_plain,
- "commit" => \&git_commit,
- "forks" => \&git_forks,
- "heads" => \&git_heads,
- "history" => \&git_history,
- "log" => \&git_log,
- "rss" => \&git_rss,
- "atom" => \&git_atom,
- "search" => \&git_search,
- "search_help" => \&git_search_help,
- "shortlog" => \&git_shortlog,
- "summary" => \&git_summary,
- "tag" => \&git_tag,
- "tags" => \&git_tags,
- "tree" => \&git_tree,
- "snapshot" => \&git_snapshot,
- "object" => \&git_object,
- # those below don't need $project
- "opml" => \&git_opml,
- "project_list" => \&git_project_list,
- "project_index" => \&git_project_index,
-);
-
if (!defined $action) {
if (defined $hash) {
$action = git_get_type($hash);
@@ -604,35 +646,12 @@ sub href (%) {
# default is to use -absolute url() i.e. $my_uri
my $href = $params{-full} ? $my_url : $my_uri;
- # XXX: Warning: If you touch this, check the search form for updating,
- # too.
-
- my @mapping = (
- project => "p",
- action => "a",
- file_name => "f",
- file_parent => "fp",
- hash => "h",
- hash_parent => "hp",
- hash_base => "hb",
- hash_parent_base => "hpb",
- page => "pg",
- order => "o",
- searchtext => "s",
- searchtype => "st",
- snapshot_format => "sf",
- extra_options => "opt",
- search_use_regexp => "sr",
- );
- my %mapping = @mapping;
-
$params{'project'} = $project unless exists $params{'project'};
if ($params{-replay}) {
- while (my ($name, $symbol) = each %mapping) {
+ while (my ($name, $symbol) = each %cgi_param_mapping) {
if (!exists $params{$name}) {
- # to allow for multivalued params we use arrayref form
- $params{$name} = [ $cgi->param($symbol) ];
+ $params{$name} = $input_params{$name};
}
}
}
@@ -651,8 +670,8 @@ sub href (%) {
# now encode the parameters explicitly
my @result = ();
- for (my $i = 0; $i < @mapping; $i += 2) {
- my ($name, $symbol) = ($mapping[$i], $mapping[$i+1]);
+ for (my $i = 0; $i < @cgi_param_mapping; $i += 2) {
+ my ($name, $symbol) = ($cgi_param_mapping[$i], $cgi_param_mapping[$i+1]);
if (defined $params{$name}) {
if (ref($params{$name}) eq "ARRAY") {
foreach my $par (@{$params{$name}}) {
@@ -672,6 +691,25 @@ sub href (%) {
## ======================================================================
## validation, quoting/unquoting and escaping
+sub validate_action {
+ my $input = shift || return undef;
+ return undef unless exists $actions{$action};
+ return $action;
+}
+
+sub validate_project {
+ my $input = shift || return undef;
+ if (!validate_pathname($input) ||
+ !(-d "$projectroot/$input") ||
+ !check_head_link("$projectroot/$input") ||
+ ($export_ok && !(-e "$projectroot/$input/$export_ok")) ||
+ ($strict_export && !project_in_list($input))) {
+ return undef;
+ } else {
+ return $input;
+ }
+}
+
sub validate_pathname {
my $input = shift || return undef;
@@ -3988,7 +4026,7 @@ sub git_search_grep_body {
## actions
sub git_project_list {
- my $order = $cgi->param('o');
+ my $order = $input_params{'order'};
if (defined $order && $order !~ m/none|project|descr|owner|age/) {
die_error(400, "Unknown order parameter");
}
@@ -4011,7 +4049,7 @@ sub git_project_list {
}
sub git_forks {
- my $order = $cgi->param('o');
+ my $order = $input_params{'order'};
if (defined $order && $order !~ m/none|project|descr|owner|age/) {
die_error(400, "Unknown order parameter");
}
@@ -4545,7 +4583,7 @@ sub git_snapshot {
my @supported_fmts = gitweb_check_feature('snapshot');
@supported_fmts = filter_snapshot_fmts(@supported_fmts);
- my $format = $cgi->param('sf');
+ my $format = $input_params{'snapshot_format'};
if (!@supported_fmts) {
die_error(403, "Snapshots not allowed");
}
--
1.5.6.5
^ permalink raw reply related
* Re: Numeric Revision Names?
From: Jeff King @ 2008-10-03 17:14 UTC (permalink / raw)
To: Stephen Haberman; +Cc: Jakub Narebski, marceloribeiro, git
In-Reply-To: <20081003115557.08d80c2f.stephen@exigencecorp.com>
On Fri, Oct 03, 2008 at 11:55:57AM -0500, Stephen Haberman wrote:
> For projects that do have a central authority (e.g. internal corporate
> projects), revision numbers make more sense.
>
> Granted, they are on separate branches (like svn), but the nice thing
> about them is that they are monotonically increasing. E.g. our qa
> people love numbers--the bug fix ticket says dev just put in
> r100...qa/production box says it is on r95. Doesn't matter the
> branch/whatever, they know the box doesn't have r100. Now, right, if
> its r105, it is trickier, although we also throw in branch name (e.g.
> topica-r100) which means no false positives but can lead to false
> negatives.
If you are constraining yourself to a central repo, then you could just
add a receive hook that tags each new commit with a monotonically
increasing revision number. Clients would get the tags upon fetch.
Something like the following (totally untested, and probably needs to
handle locking and errors more sanely) in the post-receive hook:
n=`cat revnumber 2>/dev/null || echo 0`
while read old new branch; do
git rev-list $old..$new |
while read rev; do
n=$(($n+1))
git tag r$n $rev
done
done
echo $n >revnumber
-Peff
^ permalink raw reply
* Re: Numeric Revision Names?
From: Thomas Rast @ 2008-10-03 17:13 UTC (permalink / raw)
To: Stephen Haberman; +Cc: Jakub Narebski, marceloribeiro, git
In-Reply-To: <20081003115557.08d80c2f.stephen@exigencecorp.com>
[-- Attachment #1: Type: text/plain, Size: 1770 bytes --]
Stephen Haberman wrote:
>
> > Second, in my opinion revision numbers are not that useful for
> > projects with large number of commits (where revision number might be
> > something like r4321), and nonlinear history (you don't know how r4555
> > relates to r4556: they might be on different branches).
>
> For projects that do have a central authority (e.g. internal corporate
> projects), revision numbers make more sense.
>
> Granted, they are on separate branches (like svn), but the nice thing
> about them is that they are monotonically increasing. E.g. our qa
> people love numbers--the bug fix ticket says dev just put in
> r100...qa/production box says it is on r95. Doesn't matter the
> branch/whatever, they know the box doesn't have r100. Now, right, if
> its r105, it is trickier, although we also throw in branch name (e.g.
> topica-r100) which means no false positives but can lead to false
> negatives.
I wonder how that constitutes an argument for revision numbers.
First, the _only_ guarantee you get out of monotonically increasing
revision numbers is that they're ... monotonically increasing. You
might as well use the commit (not author!) timestamp for that purpose
(assuming your clocks are all synced). They do not convey history
membership, only history non-membership, for the same obvious reason
that commit timestamps do.
Second, Git can do the check you mention above much more accurately.
If you tell QA that the fix is in 123abc, then 'git branch --contains
123abc' lists all local branches that have the fix, 'git describe
--contains 123abc' gives you the nearest tag (i.e. usually the
lowest-numbered release version number) having the fix, etc.
--
Thomas Rast
trast@{inf,student}.ethz.ch
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply
* Re: Numeric Revision Names?
From: Stephen Haberman @ 2008-10-03 16:55 UTC (permalink / raw)
To: Jakub Narebski; +Cc: marceloribeiro, git
In-Reply-To: <m3d4ihr7as.fsf@localhost.localdomain>
[-- Attachment #1: Type: text/plain, Size: 1663 bytes --]
> Second, in my opinion revision numbers are not that useful for
> projects with large number of commits (where revision number might be
> something like r4321), and nonlinear history (you don't know how r4555
> relates to r4556: they might be on different branches).
For projects that do have a central authority (e.g. internal corporate
projects), revision numbers make more sense.
Granted, they are on separate branches (like svn), but the nice thing
about them is that they are monotonically increasing. E.g. our qa
people love numbers--the bug fix ticket says dev just put in
r100...qa/production box says it is on r95. Doesn't matter the
branch/whatever, they know the box doesn't have r100. Now, right, if
its r105, it is trickier, although we also throw in branch name (e.g.
topica-r100) which means no false positives but can lead to false
negatives.
Per Robin's response and then a thread on the list a year+ ago, a
hook+tags can be used to fake this, and we're doing that now. I've been
meaning to put our hooks repo up somewhere, as we've got several fun
hooks that are focused on an internal/centralized workflow, but I
haven't gotten to it yet. For now I've just attached the commit
numbers script.
For our team, lack of monotonic version numbers was a big deal--as in
can't use git sort of big deal. I wouldn't be surprised if it is a
contributing factor that keeps other people, especially internal teams,
from git. I understand all of the reasons it can't be in git proper,
but an FAQ entry about the hook/tag hack or link to a contrib script
might be useful (not necessarily the one attached, given its
functions/etc. baggage).
- Stephen
[-- Attachment #2: functions --]
[-- Type: application/octet-stream, Size: 6725 bytes --]
#!/bin/sh
# Sets: new_commits
# Assumes: $oldrev $newrev $refname
#
# This is for use in post receive hooks, as it assumes the refname has moved and
# is now newrev, we need to discard it. This is down with bash string replace,
# as it will replace only the first match, compared to the canonical "grep -v"
# approach which will throw out multiple matches if the same commit is referred
# to by multiple branches.
#
# Excellent, excellent docs from Andy Parkin's email script
#
##################################################
#
# Consider this:
# 1 --- 2 --- O --- X --- 3 --- 4 --- N
#
# O is $oldrev for $refname
# N is $newrev for $refname
# X is a revision pointed to by some other ref, for which we may
# assume that an email has already been generated.
# In this case we want to issue an email containing only revisions
# 3, 4, and N. Given (almost) by
#
# git rev-list N ^O --not --all
#
# The reason for the "almost", is that the "--not --all" will take
# precedence over the "N", and effectively will translate to
#
# git rev-list N ^O ^X ^N
#
# So, we need to build up the list more carefully. git rev-parse
# will generate a list of revs that may be fed into git rev-list.
# We can get it to make the "--not --all" part and then filter out
# the "^N" with:
#
# git rev-parse --not --all | grep -v N
#
# Then, using the --stdin switch to git rev-list we have effectively
# manufactured
#
# git rev-list N ^O ^X
#
# This leaves a problem when someone else updates the repository
# while this script is running. Their new value of the ref we're
# working on would be included in the "--not --all" output; and as
# our $newrev would be an ancestor of that commit, it would exclude
# all of our commits. What we really want is to exclude the current
# value of $refname from the --not list, rather than N itself. So:
#
# git rev-parse --not --all | grep -v $(git rev-parse $refname)
#
# Get's us to something pretty safe (apart from the small time
# between refname being read, and git rev-parse running - for that,
# I give up)
#
#
# Next problem, consider this:
# * --- B --- * --- O ($oldrev)
# \
# * --- X --- * --- N ($newrev)
#
# That is to say, there is no guarantee that oldrev is a strict
# subset of newrev (it would have required a --force, but that's
# allowed). So, we can't simply say rev-list $oldrev..$newrev.
# Instead we find the common base of the two revs and list from
# there.
#
# As above, we need to take into account the presence of X; if
# another branch is already in the repository and points at some of
# the revisions that we are about to output - we don't want them.
# The solution is as before: git rev-parse output filtered.
#
# Finally, tags: 1 --- 2 --- O --- T --- 3 --- 4 --- N
#
# Tags pushed into the repository generate nice shortlog emails that
# summarise the commits between them and the previous tag. However,
# those emails don't include the full commit messages that we output
# for a branch update. Therefore we still want to output revisions
# that have been output on a tag email.
#
# Luckily, git rev-parse includes just the tool. Instead of using
# "--all" we use "--branches"; this has the added benefit that
# "remotes/" will be ignored as well.
#
##################################################
function set_new_commits() {
nl=$'\n'
# Get all the current branches, not'd as we want only new ones
new_commits=$(git rev-parse --not --branches)
# Strip off the not current branch
new_hash=$(git rev-parse $refname)
new_commits=${new_commits/^$new_hash/}
# Put back newrev without the not
new_commits=${new_commits}${nl}${newrev}
# Put in ^oldrev if it's not a new branch
if [ "$oldrev" != "0000000000000000000000000000000000000000" ] ; then
new_commits=${new_commits}${nl}^${oldrev}
fi
new_commits=${new_commits/$nl$nl/$nl}
new_commits=${new_commits/#$nl/}
}
# Sets: $change_type
# Assumes: $oldrev $newrev
#
# --- Interpret
# 0000->1234 (create)
# 1234->2345 (update)
# 2345->0000 (delete)
function set_change_type() {
if [ "$oldrev" == "0000000000000000000000000000000000000000" ] ; then
change_type="create"
else
if [ "$newrev" == "0000000000000000000000000000000000000000" ] ; then
change_type="delete"
else
change_type="update"
fi
fi
}
# Sets: $newrev_type $oldrev_type $rev $rev_type
# Assumes: $newrev $oldrev
# --- Get the revision types
function set_rev_types() {
newrev_type=$(git cat-file -t "$newrev" 2> /dev/null)
oldrev_type=$(git cat-file -t "$oldrev" 2> /dev/null)
if [ "$newrev" == "0000000000000000000000000000000000000000" ] ; then
rev_type="$oldrev_type"
rev="$oldrev"
else
rev_type="$newrev_type"
rev="$newrev"
fi
}
# Sets: $describe
# Assumes: $rev
#
# The email subject will contain the best description of the ref that we can build from the parameters
function set_describe() {
rev_to_describe="$rev"
if [ "$1" != "" ] ; then
rev_to_describe="$1"
fi
describe=$(git describe $rev_to_describe 2>/dev/null)
if [ -z "$describe" ]; then
describe=$rev_to_describe
fi
}
# Sets: $describe_tags
# Assumes: $rev
#
# The email subject will contain the best description of the ref that we can build from the parameters
function set_describe_tags() {
rev_to_describe="$rev"
if [ "$1" != "" ] ; then
rev_to_describe="$1"
fi
describe_tags=$(git describe --tags $rev_to_describe 2>/dev/null)
if [ -z "$describe_tags" ]; then
describe_tags=$rev_to_describe
fi
}
# Takes a lockfile path and command to execute once the lock is acquired.
#
# Retries every second for 5 minutes.
#
# with_lock "foo.lock" "echo a" # Works
# with_lock "foo.lock" "echo b1 ; echo b2" # Work
# function several() {
# echo several1 ; echo several2
# }
# with_lock "foo.lock" several # Works
#
function with_lock() {
lockfile="$1"
block="$2"
with_lock_has_lock=1
trap with_lock_unlock_if_held INT TERM EXIT
lockfile -1 -r 300 "$lockfile"
with_lock_has_lock=$?
if [ $with_lock_has_lock -ne 0 ] ; then
exit $?
fi
eval "$block"
rm -f "$lockfile"
with_lock_has_lock=1
}
function with_lock_unlock_if_held() {
if [[ "$with_lock_has_lock" -eq 0 ]] ; then
rm -f "$lockfile"
fi
}
function display_error_message() {
echo "----------------------------------------------------" >&2
echo "" >&2
echo "" >&2
for ((i=1;i<=$#;i+=1)); do
eval message="$"$i
echo "$message" >&2
done
echo "" >&2
echo "" >&2
echo "----------------------------------------------------" >&2
}
[-- Attachment #3: post-receive-assign-commit-numbers --]
[-- Type: application/octet-stream, Size: 502 bytes --]
#!/bin/sh
. $(dirname $0)/functions
while read oldrev newrev refname ; do
set_new_commits
echo "$new_commits" | git rev-list --reverse --stdin | while read commit ; do
if [[ $(grep "$commit" "$GIT_DIR/commitnumbers" 2>/dev/null) == "" ]] ; then
with_lock "$GIT_DIR/commitnumbers.lock" 'echo "$commit $refname" >> "$GIT_DIR/commitnumbers"'
number=$(grep --max-count=1 --line-number "$commit" "$GIT_DIR/commitnumbers" | grep -oP "^\d+(?=:)")
git tag "r/$number" "$commit"
fi
done
done
^ permalink raw reply
* [FYI PATCH] bash completion: alias 'g' to 'git' with completion
From: Thomas Rast @ 2008-10-03 16:35 UTC (permalink / raw)
To: git; +Cc: Rob Sanheim, Shawn O. Pearce
In-Reply-To: <fc113d400810030825l75f9451dwc4cbf68807be0b5b@mail.gmail.com>
---
Rob Sanheim wrote:
> On Thu, Oct 2, 2008 at 11:10 PM, Shawn O. Pearce <spearce@spearce.org> wrote:
> > No, you'll need to alias 'g' to git in bash, and then if you still
> > want completion you'll need to also register the compgen to call
> > _git completion routine. Its two lines:
> >
> > alias g=git
> > complete -o default -o nospace -F _git g
>
> Thanks, that did it.
Actually it's not enough, you need to teach fetch, pull and push to
recognise the new alias too, as in this patch. I do wonder if there's
a better approach to those functions however, so that the "obvious"
fix suggested by Shawn would work.
- Thomas
contrib/completion/git-completion.bash | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 7284c3b..547e735 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -789,7 +789,7 @@ _git_fetch ()
git-fetch*,1)
__gitcomp "$(__git_remotes)"
;;
- git,2)
+ git,2|g,2)
__gitcomp "$(__git_remotes)"
;;
*)
@@ -1053,7 +1053,7 @@ _git_pull ()
git-pull*,1)
__gitcomp "$(__git_remotes)"
;;
- git,2)
+ git,2|g,2)
__gitcomp "$(__git_remotes)"
;;
*)
@@ -1075,7 +1075,7 @@ _git_push ()
git-push*,1)
__gitcomp "$(__git_remotes)"
;;
- git,2)
+ git,2|g,2)
__gitcomp "$(__git_remotes)"
;;
*)
@@ -1717,6 +1717,7 @@ _gitk ()
}
complete -o default -o nospace -F _git git
+complete -o default -o nospace -F _git g
complete -o default -o nospace -F _gitk gitk
# The following are necessary only for Cygwin, and only are needed
--
1.6.0.2.771.g3967
^ permalink raw reply related
* [RFC PATCH (BUG)] builtin-blame: Fix blame -C -C with submodules.
From: Alexander Gavrilov @ 2008-10-03 16:23 UTC (permalink / raw)
To: Git Mailing List; +Cc: Junio C Hamano, Shawn O. Pearce
When performing copy detection, git-blame tries to
read gitlinks as blobs, which causes it to die.
This patch adds a check to skip them.
Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
---
I don't know if this is enough for all cases, but it fixes mine.
-- Alexander
$ git blame --incremental -C -C ImpactMessages.cpp
767f36d1ce2f361e9148bb23155e6aafad034f4b 6 6 10
...
767f36d1ce2f361e9148bb23155e6aafad034f4b 49 49 7
filename BackEnd/Impact/ImpactMessages.cpp
767f36d1ce2f361e9148bb23155e6aafad034f4b 57 57 1
filename BackEnd/Impact/ImpactMessages.cpp
767f36d1ce2f361e9148bb23155e6aafad034f4b 59 59 14
filename BackEnd/Impact/ImpactMessages.cpp
fatal: Cannot read blob 27152bb4f8b10d4ce5f9fa584c14511dceba3c06 for path BackEnd/Boost
builtin-blame.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/builtin-blame.c b/builtin-blame.c
index 9bc901c..101c416 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -1136,6 +1136,8 @@ static int find_copy_in_parent(struct scoreboard *sb,
if (!DIFF_FILE_VALID(p->one))
continue; /* does not exist in parent */
+ if (S_ISGITLINK(p->one->mode))
+ continue; /* ignore git links */
if (porigin && !strcmp(p->one->path, porigin->path))
/* find_move already dealt with this path */
continue;
--
1.6.0.20.g6148bc
^ permalink raw reply related
* Re: Numeric Revision Names?
From: Jakub Narebski @ 2008-10-03 16:07 UTC (permalink / raw)
To: marceloribeiro; +Cc: git
In-Reply-To: <19796862.post@talk.nabble.com>
marceloribeiro <marcelo@sonnay.com> writes:
> I am new to git, and my question may be stupid, but anyway...
> I am used to the numeric revision names on svn, and on Git
> all I get are hexadecimal names.
>
> Is there any way to configure it to start a projects revisions on
> lets say, revision 0, and keep incrementing it after each commit?
>
> I tried finding it on git doc but wasnt able to. Maybe I am missing
> something....
First, it is simply not possible to have incremental revision numbers
in distributed version control system like Git, at least not without
some central authority (assigning revision numbers). Other distributed
SCM use simple revision numbers, but either they are local to branch
and local to repository (not shared) as in case of Mercurial, or
require centralized workflow where one uses different merge than in
leaf repositories, as from what I understand is the case with dotted
revision numbers in Bazaar-NG.
Second, in my opinion revision numbers are not that useful for
projects with large number of commits (where revision number might be
something like r4321), and nonlinear history (you don't know how r4555
relates to r4556: they might be on different branches). Also you
don't have to use full revision numbers: you can use shortened
revision numbers (usually 6-8 characters is enough, e.g. 5f2d4160);
if you use tags to mark released versions you can use git-describe
output to count revisions from given tag (output contains sha-1
because history migh branch after tag, and number of commits since tag
is not enough to determine commit/revision; e.g. v1.6.0-rc3-17-gc14c8ce
which means 17 commits after tag v1.6.0-rc3).
Additionally when using git you usually use transient revision
numbers, counting commits from tip of branch, for example master~5
means 5 commits in first-parent line from what branch 'master' points
to now.
--
Jakub Narebski
Poland
ShadeHawk on #git
^ permalink raw reply
* Re: [FYI][PATCH] Execute testsuite on existing Git installation
From: Rogan Dawes @ 2008-10-03 15:59 UTC (permalink / raw)
Cc: Petr Baudis, git
In-Reply-To: <48E6314B.3090609@dawes.za.net>
Rogan Dawes wrote:
> Petr Baudis wrote:
>> When I joined here, one of the first tasks I had was to "verify if the
>> existing system-wide Git installation works fine on the local Linux
>> setup (of unknown qualities)". I couldn't think of anything better than
>> to run the Git testsuite, but using the system-wide Git instead of
>> locally compiled one.
>>
>> This extremely dirty patch achieves this; patch testsuite of Git version
>> corresponding to the system-wide installation, of course. You will still
>> need to make the test helpers.
>>
>> I don't have any real interest on developing this further or tidying it
>> up, but I have thought that someone might find this useful to just use
>> or push forward, so here it goes.
>>
>> Signed-off-by: Petr Baudis <petr.baudis@novartis.com>
>>
>
> Perhaps a stupid question, but might it not be easier to add the git
> build dir to the front of the PATH, and then remove the explicit paths?
>
> I realise that if the build was unsuccessful, you may end up executing a
> different version of git than you expect, though.
>
> Rogan
>
Or, make a "BUILD_DIR" variable, and replace ../git with ${BUILD_DIR}git
throughout, and make BUILD_DIR == '../' for the normal case, and '' for
the less common case of testing the existing installation.
Or, make ../git a symlink to the installed git binary. This is probably
the simplest, in fact, requiring the least surgery - i.e. none for those
who don't need this functionality.
Rogan
^ permalink raw reply
* Re: alias g to git in .gitconfig?
From: Rob Sanheim @ 2008-10-03 15:25 UTC (permalink / raw)
To: git
In-Reply-To: <20081003031014.GA24367@spearce.org>
Thanks, that did it.
On Thu, Oct 2, 2008 at 11:10 PM, Shawn O. Pearce <spearce@spearce.org> wrote:
> Rob Sanheim <rsanheim@gmail.com> wrote:
>> This is pretty trivial, but I'm a lazy typist.
>>
>> Is it possible to alias 'g' to git via git config, instead of via
>> bash? If I do a plain bash alias then none of the nice autocompletion
>> from git-contrib work with 'g'.
>
> No, you'll need to alias 'g' to git in bash, and then if you still
> want completion you'll need to also register the compgen to call
> _git completion routine. Its two lines:
>
> alias g=git
> complete -o default -o nospace -F _git g
>
> --
> Shawn.
>
^ permalink raw reply
* [PATCH] builtin-commit: use reduce_heads() only when appropriate
From: SZEDER Gábor @ 2008-10-03 15:09 UTC (permalink / raw)
To: Miklos Vajna, Shawn O. Pearce; +Cc: jnareb, Johannes.Schindelin, git
In-Reply-To: <1223035487-2576-1-git-send-email-vmiklos@frugalware.org>
Since commit 6bb6b034 (builtin-commit: use commit_tree(), 2008-09-10),
builtin-commit performs a reduce_heads() unconditionally. However,
it's not always needed, and in some cases even harmful.
reduce_heads() is not needed for the initial commit or for an
"ordinary" commit, because they don't have any or have only one
parent, respectively.
reduce_heads() must be avoided when 'git commit' is run after a 'git
merge --no-ff --no-commit', otherwise it will turn the
non-fast-forward merge into fast-forward. For the same reason,
reduce_heads() must be avoided when amending such a merge commit.
To resolve this issue, 'git merge' will write info about whether
fast-forward is allowed or not to $GIT_DIR/MERGE_MODE. Based on this
info, 'git commit' will only perform reduce_heads() when it's
committing a merge and fast-forward is enabled.
Also add test cases to ensure that non-fast-forward merges are
committed and amended properly.
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
---
I think this should be squashed onto Miklós' patch.
First, it fixes the segmentation fault caused by using the strbuf
before initializing it. Second, amending a no-ff merge commit has
the same issues with reduce_heads(); see the new test case. And the
commit message is also more detailed ;)
I'm not sure about putting these two new test into t7600-merge.sh.
Although the infrastructure to keep these tests very short (repo with
branches already set up, verify_parents) is there available, the first
test tests not only merge, but the cooperation of merge and commit,
and this second one tests only commit.
Regards,
Gábor
builtin-commit.c | 21 +++++++++++----------
t/t7600-merge.sh | 7 +++++++
2 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/builtin-commit.c b/builtin-commit.c
index e69b4af..93f360f 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -953,6 +953,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
return 1;
}
+ strbuf_init(&sb, 0);
/* Determine parents */
if (initial_commit) {
reflog_msg = "commit (initial)";
@@ -986,22 +987,22 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
}
fclose(fp);
strbuf_release(&m);
+ if (!stat(git_path("MERGE_MODE"), &statbuf)) {
+ if (strbuf_read_file(&sb, git_path("MERGE_MODE"), 0) < 0)
+ die("could not read MERGE_MODE: %s",
+ strerror(errno));
+ if (!strcmp(sb.buf, "no-ff"))
+ allow_fast_forward = 0;
+ }
+ if (allow_fast_forward)
+ parents = reduce_heads(parents);
} else {
reflog_msg = "commit";
pptr = &commit_list_insert(lookup_commit(head_sha1), pptr)->next;
}
- strbuf_reset(&sb);
- if (!stat(git_path("MERGE_MODE"), &statbuf)) {
- if (strbuf_read_file(&sb, git_path("MERGE_MODE"), 0) < 0)
- die("could not read MERGE_MODE: %s", strerror(errno));
- if (!strcmp(sb.buf, "no-ff"))
- allow_fast_forward = 0;
- }
- if (allow_fast_forward)
- parents = reduce_heads(parents);
/* Finally, get the commit message */
- strbuf_init(&sb, 0);
+ strbuf_reset(&sb);
if (strbuf_read_file(&sb, git_path(commit_editmsg), 0) < 0) {
rollback_index_files();
die("could not read commit message");
diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
index 98cfc53..209d7cd 100755
--- a/t/t7600-merge.sh
+++ b/t/t7600-merge.sh
@@ -520,4 +520,11 @@ test_expect_success 'merge --no-ff --no-commit && commit' '
test_debug 'gitk --all'
+test_expect_success 'amending no-ff merge commit' '
+ EDITOR=: git commit --amend &&
+ verify_parents $c0 $c1
+'
+
+test_debug 'gitk --all'
+
test_done
--
1.6.0.2.430.gfc53
^ permalink raw reply related
* Re: [PATCH] builtin-commit: avoid always using reduce_heads()
From: Shawn O. Pearce @ 2008-10-03 14:59 UTC (permalink / raw)
To: Miklos Vajna; +Cc: SZEDER Gabor, jnareb, Johannes.Schindelin, git
In-Reply-To: <1223035487-2576-1-git-send-email-vmiklos@frugalware.org>
Miklos Vajna <vmiklos@frugalware.org> wrote:
> In case git merge --no-ff is used with --no-commit or we have a
> conflict, write info about if fast forwards are allowed or not to
> $GIT_DIR/MERGE_MODE.
*sigh*
$ git co -b mv/merge-noff master && git am -s <this
$ make test
...
*** t0004-unwritable.sh ***
* FAIL 1: setup
...
$ cd t && ./t0004-unwritable.sh -i -v
...
./test-lib.sh: line 237: 362 Segmentation fault git commit -m initial
* FAIL 1: setup
I leave the debugging to you. ;-)
--
Shawn.
^ permalink raw reply
* Re: [FYI][PATCH] Execute testsuite on existing Git installation
From: Rogan Dawes @ 2008-10-03 14:50 UTC (permalink / raw)
To: Petr Baudis; +Cc: git
In-Reply-To: <20081003131314.GS10544@machine.or.cz>
Petr Baudis wrote:
> When I joined here, one of the first tasks I had was to "verify if the
> existing system-wide Git installation works fine on the local Linux
> setup (of unknown qualities)". I couldn't think of anything better than
> to run the Git testsuite, but using the system-wide Git instead of
> locally compiled one.
>
> This extremely dirty patch achieves this; patch testsuite of Git version
> corresponding to the system-wide installation, of course. You will still
> need to make the test helpers.
>
> I don't have any real interest on developing this further or tidying it
> up, but I have thought that someone might find this useful to just use
> or push forward, so here it goes.
>
> Signed-off-by: Petr Baudis <petr.baudis@novartis.com>
>
Perhaps a stupid question, but might it not be easier to add the git
build dir to the front of the PATH, and then remove the explicit paths?
I realise that if the build was unsuccessful, you may end up executing a
different version of git than you expect, though.
Rogan
^ permalink raw reply
* Re: [PATCH] Do not rename read-only files during a push
From: Miklos Vajna @ 2008-10-03 14:19 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: Petr Baudis, git
In-Reply-To: <20081003141628.GV21310@spearce.org>
[-- Attachment #1: Type: text/plain, Size: 269 bytes --]
On Fri, Oct 03, 2008 at 07:16:28AM -0700, "Shawn O. Pearce" <spearce@spearce.org> wrote:
> Hmmph. It got dropped by accident. I don't remember seeing this
> patch via email, and its not on GMane.
It has a duplicated To: header, probably it was filtered out as spam.
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply
* Re: [PATCH] Do not rename read-only files during a push
From: Shawn O. Pearce @ 2008-10-03 14:16 UTC (permalink / raw)
To: Petr Baudis; +Cc: git
In-Reply-To: <20081003102043.GR10544@machine.or.cz>
Petr Baudis <pasky@suse.cz> wrote:
> On Mon, Sep 22, 2008 at 07:20:29PM +0200, Petr Baudis wrote:
> > Win32 does not allow renaming read-only files (at least on a Samba
> > share), making push into a local directory to fail. Thus, defer
> > the chmod() call in index-pack.c:final() only after
> > move_temp_to_file() was called.
> >
> > Signed-off-by: Petr Baudis <pasky@suse.cz>
>
> Ping?
Hmmph. It got dropped by accident. I don't remember seeing this
patch via email, and its not on GMane. I found it on marc and am
applying it right now. Thanks for the reminder.
--
Shawn.
^ permalink raw reply
* Re: [PATCH] git commit: Repaint the output format bikeshed (again)
From: Shawn O. Pearce @ 2008-10-03 14:09 UTC (permalink / raw)
To: Jeff King; +Cc: Andreas Ericsson, Git Mailing List
In-Reply-To: <20081003042405.GB1839@coredump.intra.peff.net>
Jeff King <peff@peff.net> wrote:
> On Thu, Oct 02, 2008 at 05:15:56PM -0700, Shawn O. Pearce wrote:
>
> > I think painting is over for now. Time to let the paint dry.
> > I applied Jeff's patch:
> >
> > [jk/bikeshed] created bd8098f: "reformat informational commit message"
>
> Woo! Victory by attrition!
I think the hard part now is to get the user docs updated to reflect
the new format. We need to get that done before this can merge
over to master.
--
Shawn.
^ permalink raw reply
* [PATCH] gitweb: Unify shortlog/log links
From: Petr Baudis @ 2008-10-03 13:45 UTC (permalink / raw)
To: git, git; +Cc: Petr Baudis
In-Reply-To: <1222958212-5896-1-git-send-email-pasky@suse.cz>
Instead of 'shortlog | log', we use only 'log' now, pointing to the shortlog
action, since that is what most people are usually interested in first. In the
action-specific navbar, you can then choose between short and full log view.
The aim of this patch is to reduce the overwhelming number of links by
including only orthogonal links to most popular views.
Signed-off-by: Petr Baudis <petr.baudis@novartis.com>
---
gitweb/gitweb.perl | 46 +++++++++++++++++++++++++++++++++-------------
1 files changed, 33 insertions(+), 13 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 9fbc9f8..58fc137 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2761,7 +2761,7 @@ sub git_print_page_nav {
my ($current, $suppress, $head, $treehead, $treebase, $extra) = @_;
$extra = '' if !defined $extra; # pager or formats
- my @navs = qw(summary shortlog log commit commitdiff tree);
+ my @navs = qw(summary log commit commitdiff tree);
if ($suppress) {
@navs = grep { $_ ne $suppress } @navs;
}
@@ -2772,12 +2772,11 @@ sub git_print_page_nav {
$arg{$_}{'hash'} = $head;
}
if ($current =~ m/^(tree | log | shortlog | commit | commitdiff | search)$/x) {
- for (qw(shortlog log)) {
- $arg{$_}{'hash'} = $head;
- }
+ $arg{'log'}{'hash'} = $head;
}
}
+ $arg{'log'}{'action'} = 'shortlog';
$arg{'tree'}{'hash'} = $treehead if defined $treehead;
$arg{'tree'}{'hash_base'} = $treebase if defined $treebase;
@@ -2832,6 +2831,26 @@ sub format_paging_nav {
return $paging_nav;
}
+sub format_log_nav {
+ my ($action, $hash, $head, $page, $has_next_link) = @_;
+ my $paging_nav;
+
+ if ($action eq 'shortlog') {
+ $paging_nav .= 'shortlog';
+ } else {
+ $paging_nav .= $cgi->a({-href => href(action=>'shortlog', -replay=>1)}, 'shortlog');
+ }
+ $paging_nav .= ' | ';
+ if ($action eq 'log') {
+ $paging_nav .= 'fulllog';
+ } else {
+ $paging_nav .= $cgi->a({-href => href(action=>'log', -replay=>1)}, 'fulllog');
+ }
+
+ $paging_nav .= " | " . format_paging_nav($action, $hash, $head, $page, $has_next_link);
+ return $paging_nav;
+}
+
## ......................................................................
## functions printing or outputting HTML: div
@@ -3722,8 +3741,7 @@ sub git_project_list_body {
(defined $pr->{'age_string'} ? $pr->{'age_string'} : "No commits") . "</td>\n" .
"<td class=\"link\">" .
$cgi->a({-href => href(project=>$pr->{'path'}, action=>"summary")}, "summary") . " | " .
- $cgi->a({-href => href(project=>$pr->{'path'}, action=>"shortlog")}, "shortlog") . " | " .
- $cgi->a({-href => href(project=>$pr->{'path'}, action=>"log")}, "log") . " | " .
+ $cgi->a({-href => href(project=>$pr->{'path'}, action=>"shortlog")}, "log") . " | " .
$cgi->a({-href => href(project=>$pr->{'path'}, action=>"tree")}, "tree") .
($pr->{'forks'} ? " | " . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"forks")}, "forks") : '') .
"</td>\n" .
@@ -3894,8 +3912,7 @@ sub git_tags_body {
"<td class=\"link\">" . " | " .
$cgi->a({-href => href(action=>$tag{'reftype'}, hash=>$tag{'refid'})}, $tag{'reftype'});
if ($tag{'reftype'} eq "commit") {
- print " | " . $cgi->a({-href => href(action=>"shortlog", hash=>$tag{'fullname'})}, "shortlog") .
- " | " . $cgi->a({-href => href(action=>"log", hash=>$tag{'fullname'})}, "log");
+ print " | " . $cgi->a({-href => href(action=>"shortlog", hash=>$tag{'fullname'})}, "log");
} elsif ($tag{'reftype'} eq "blob") {
print " | " . $cgi->a({-href => href(action=>"blob_plain", hash=>$tag{'refid'})}, "raw");
}
@@ -3934,8 +3951,7 @@ sub git_heads_body {
-class => "list name"},esc_html($ref{'name'})) .
"</td>\n" .
"<td class=\"link\">" .
- $cgi->a({-href => href(action=>"shortlog", hash=>$ref{'fullname'})}, "shortlog") . " | " .
- $cgi->a({-href => href(action=>"log", hash=>$ref{'fullname'})}, "log") . " | " .
+ $cgi->a({-href => href(action=>"shortlog", hash=>$ref{'fullname'})}, "log") . " | " .
$cgi->a({-href => href(action=>"tree", hash=>$ref{'fullname'}, hash_base=>$ref{'name'})}, "tree") .
"</td>\n" .
"</tr>";
@@ -4628,9 +4644,12 @@ sub git_log {
my @commitlist = parse_commits($hash, 101, (100 * $page));
- my $paging_nav = format_paging_nav('log', $hash, $head, $page, $#commitlist >= 100);
+ my $paging_nav = format_log_nav('log', $hash, $head, $page, $#commitlist >= 100);
- git_header_html();
+ {
+ local $action = 'fulllog';
+ git_header_html();
+ }
git_print_page_nav('log','', $hash,undef,undef, $paging_nav);
if (!@commitlist) {
@@ -5533,7 +5552,8 @@ sub git_shortlog {
my @commitlist = parse_commits($hash, 101, (100 * $page));
- my $paging_nav = format_paging_nav('shortlog', $hash, $head, $page, $#commitlist >= 100);
+ my $paging_nav = format_log_nav('shortlog', $hash, $head, $page, $#commitlist >= 100);
+
my $next_link = '';
if ($#commitlist >= 100) {
$next_link =
--
tg: (7fac06d..) t/extra-actions/log-consolidate (depends on: t/extra-actions/extra-actions)
^ permalink raw reply related
* [FYI][PATCH] Execute testsuite on existing Git installation
From: Petr Baudis @ 2008-10-03 13:13 UTC (permalink / raw)
To: git
When I joined here, one of the first tasks I had was to "verify if the
existing system-wide Git installation works fine on the local Linux
setup (of unknown qualities)". I couldn't think of anything better than
to run the Git testsuite, but using the system-wide Git instead of
locally compiled one.
This extremely dirty patch achieves this; patch testsuite of Git version
corresponding to the system-wide installation, of course. You will still
need to make the test helpers.
I don't have any real interest on developing this further or tidying it
up, but I have thought that someone might find this useful to just use
or push forward, so here it goes.
Signed-off-by: Petr Baudis <petr.baudis@novartis.com>
---
diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh
index 5d3bd9d..f3c78dc 100644
--- a/t/lib-git-svn.sh
+++ b/t/lib-git-svn.sh
@@ -47,7 +47,7 @@ rawsvnrepo="$svnrepo"
svnrepo="file://$svnrepo"
poke() {
- test-chmtime +1 "$1"
+ ~/git-repo/test-chmtime +1 "$1"
}
for d in \
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 690f80a..606ed99 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -21,11 +21,13 @@ modification *should* take notice and update the test vectors here.
################################################################
# It appears that people try to run tests without building...
-../git >/dev/null
-if test $? != 1
-then
- echo >&2 'You do not seem to have built git yet.'
- exit 1
+if false; then
+ ../git >/dev/null
+ if test $? != 1
+ then
+ echo >&2 'You do not seem to have built git yet.'
+ exit 1
+ fi
fi
. ./test-lib.sh
@@ -301,14 +303,14 @@ test_expect_success 'absolute path works as expected' '
mkdir third &&
dir="$(cd .git; pwd -P)" &&
dir2=third/../second/other/.git &&
- test "$dir" = "$(test-absolute-path $dir2)" &&
+ test "$dir" = "$(~/git-repo/test-absolute-path $dir2)" &&
file="$dir"/index &&
- test "$file" = "$(test-absolute-path $dir2/index)" &&
+ test "$file" = "$(~/git-repo/test-absolute-path $dir2/index)" &&
basename=blub &&
- test "$dir/$basename" = "$(cd .git && test-absolute-path "$basename")" &&
+ test "$dir/$basename" = "$(cd .git && ~/git-repo/test-absolute-path "$basename")" &&
ln -s ../first/file .git/syml &&
sym="$(cd first; pwd -P)"/file &&
- test "$sym" = "$(test-absolute-path "$dir2/syml")"
+ test "$sym" = "$(~/git-repo/test-absolute-path "$dir2/syml")"
'
test_expect_success 'very long name in the index handled sanely' '
diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh
index 6309aed..7d13c3f 100755
--- a/t/t0040-parse-options.sh
+++ b/t/t0040-parse-options.sh
@@ -39,7 +39,7 @@ Standard options
EOF
test_expect_success 'test help' '
- test_must_fail test-parse-options -h > output 2> output.err &&
+ test_must_fail ~/git-repo/test-parse-options -h > output 2> output.err &&
test ! -s output &&
test_cmp expect.err output.err
'
@@ -55,7 +55,7 @@ dry run: yes
EOF
test_expect_success 'short options' '
- test-parse-options -s123 -b -i 1729 -b -vv -n > output 2> output.err &&
+ ~/git-repo/test-parse-options -s123 -b -i 1729 -b -vv -n > output 2> output.err &&
test_cmp expect output &&
test ! -s output.err
'
@@ -71,7 +71,7 @@ dry run: no
EOF
test_expect_success 'long options' '
- test-parse-options --boolean --integer 1729 --boolean --string2=321 \
+ ~/git-repo/test-parse-options --boolean --integer 1729 --boolean --string2=321 \
--verbose --verbose --no-dry-run --abbrev=10 \
> output 2> output.err &&
test ! -s output.err &&
@@ -92,7 +92,7 @@ arg 02: --boolean
EOF
test_expect_success 'intermingled arguments' '
- test-parse-options a1 --string 123 b1 --boolean -j 13 -- --boolean \
+ ~/git-repo/test-parse-options a1 --string 123 b1 --boolean -j 13 -- --boolean \
> output 2> output.err &&
test ! -s output.err &&
test_cmp expect output
@@ -109,19 +109,19 @@ dry run: no
EOF
test_expect_success 'unambiguously abbreviated option' '
- test-parse-options --int 2 --boolean --no-bo > output 2> output.err &&
+ ~/git-repo/test-parse-options --int 2 --boolean --no-bo > output 2> output.err &&
test ! -s output.err &&
test_cmp expect output
'
test_expect_success 'unambiguously abbreviated option with "="' '
- test-parse-options --int=2 > output 2> output.err &&
+ ~/git-repo/test-parse-options --int=2 > output 2> output.err &&
test ! -s output.err &&
test_cmp expect output
'
test_expect_success 'ambiguously abbreviated option' '
- test-parse-options --strin 123;
+ ~/git-repo/test-parse-options --strin 123;
test $? = 129
'
@@ -136,7 +136,7 @@ dry run: no
EOF
test_expect_success 'non ambiguous option (after two options it abbreviates)' '
- test-parse-options --st 123 > output 2> output.err &&
+ ~/git-repo/test-parse-options --st 123 > output 2> output.err &&
test ! -s output.err &&
test_cmp expect output
'
@@ -146,7 +146,7 @@ error: did you mean \`--boolean\` (with two dashes ?)
EOF
test_expect_success 'detect possible typos' '
- test_must_fail test-parse-options -boolean > output 2> output.err &&
+ test_must_fail ~/git-repo/test-parse-options -boolean > output 2> output.err &&
test ! -s output &&
test_cmp typo.err output.err
'
@@ -163,7 +163,7 @@ arg 00: --quux
EOF
test_expect_success 'keep some options as arguments' '
- test-parse-options --quux > output 2> output.err &&
+ ~/git-repo/test-parse-options --quux > output 2> output.err &&
test ! -s output.err &&
test_cmp expect output
'
@@ -180,7 +180,7 @@ arg 00: foo
EOF
test_expect_success 'OPT_DATE() and OPT_SET_PTR() work' '
- test-parse-options -t "1970-01-01 00:00:01 +0000" --default-string \
+ ~/git-repo/test-parse-options -t "1970-01-01 00:00:01 +0000" --default-string \
foo -q > output 2> output.err &&
test ! -s output.err &&
test_cmp expect output
@@ -198,7 +198,7 @@ dry run: no
EOF
test_expect_success 'OPT_CALLBACK() and OPT_BIT() work' '
- test-parse-options --length=four -b -4 > output 2> output.err &&
+ ~/git-repo/test-parse-options --length=four -b -4 > output 2> output.err &&
test ! -s output.err &&
test_cmp expect output
'
@@ -208,7 +208,7 @@ Callback: "not set", 1
EOF
test_expect_success 'OPT_CALLBACK() and callback errors work' '
- test_must_fail test-parse-options --no-length > output 2> output.err &&
+ test_must_fail ~/git-repo/test-parse-options --no-length > output 2> output.err &&
test_cmp expect output &&
test_cmp expect.err output.err
'
@@ -224,7 +224,7 @@ dry run: no
EOF
test_expect_success 'OPT_BIT() and OPT_SET_INT() work' '
- test-parse-options --set23 -bbbbb --no-or4 > output 2> output.err &&
+ ~/git-repo/test-parse-options --set23 -bbbbb --no-or4 > output 2> output.err &&
test ! -s output.err &&
test_cmp expect output
'
diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh
index 85d7e3e..2e869f4 100755
--- a/t/t4200-rerere.sh
+++ b/t/t4200-rerere.sh
@@ -149,16 +149,16 @@ just_over_15_days_ago=$((-1-15*86400))
almost_60_days_ago=$((60-60*86400))
just_over_60_days_ago=$((-1-60*86400))
-test-chmtime =$almost_60_days_ago $rr/preimage
-test-chmtime =$almost_15_days_ago $rr2/preimage
+~/git-repo/test-chmtime =$almost_60_days_ago $rr/preimage
+~/git-repo/test-chmtime =$almost_15_days_ago $rr2/preimage
test_expect_success 'garbage collection (part1)' 'git rerere gc'
test_expect_success 'young records still live' \
"test -f $rr/preimage && test -f $rr2/preimage"
-test-chmtime =$just_over_60_days_ago $rr/preimage
-test-chmtime =$just_over_15_days_ago $rr2/preimage
+~/git-repo/test-chmtime =$just_over_60_days_ago $rr/preimage
+~/git-repo/test-chmtime =$just_over_15_days_ago $rr2/preimage
test_expect_success 'garbage collection (part2)' 'git rerere gc'
diff --git a/t/t5301-sliding-window.sh b/t/t5301-sliding-window.sh
index 073ac0c..89177ab 100755
--- a/t/t5301-sliding-window.sh
+++ b/t/t5301-sliding-window.sh
@@ -12,7 +12,7 @@ test_expect_success \
for i in a b c
do
echo $i >$i &&
- test-genrandom "$i" 32768 >>$i &&
+ ~/git-repo/test-genrandom "$i" 32768 >>$i &&
git update-index --add $i || return 1
done &&
echo d >d && cat c >>d && git update-index --add d &&
diff --git a/t/t5302-pack-index.sh b/t/t5302-pack-index.sh
index 09fd917..a38c0c2 100755
--- a/t/t5302-pack-index.sh
+++ b/t/t5302-pack-index.sh
@@ -15,11 +15,11 @@ test_expect_success \
do
i=`printf '%03i' $i`
echo $i >file_$i &&
- test-genrandom "$i" 8192 >>file_$i &&
+ ~/git-repo/test-genrandom "$i" 8192 >>file_$i &&
git update-index --add file_$i &&
i=`expr $i + 1` || return 1
done &&
- { echo 101 && test-genrandom 100 8192; } >file_101 &&
+ { echo 101 && ~/git-repo/test-genrandom 100 8192; } >file_101 &&
git update-index --add file_101 &&
tree=`git write-tree` &&
commit=`git commit-tree $tree </dev/null` && {
diff --git a/t/t5304-prune.sh b/t/t5304-prune.sh
index 9fd9d07..6084172 100644
--- a/t/t5304-prune.sh
+++ b/t/t5304-prune.sh
@@ -21,7 +21,7 @@ test_expect_success 'prune stale packs' '
orig_pack=$(echo .git/objects/pack/*.pack) &&
: > .git/objects/tmp_1.pack &&
: > .git/objects/tmp_2.pack &&
- test-chmtime -86501 .git/objects/tmp_1.pack &&
+ ~/git-repo/test-chmtime -86501 .git/objects/tmp_1.pack &&
git prune --expire 1.day &&
test -f $orig_pack &&
test -f .git/objects/tmp_2.pack &&
@@ -39,7 +39,7 @@ test_expect_success 'prune --expire' '
git prune --expire=1.hour.ago &&
test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
test -f $BLOB_FILE &&
- test-chmtime -86500 $BLOB_FILE &&
+ ~/git-repo/test-chmtime -86500 $BLOB_FILE &&
git prune --expire 1.day &&
test $before = $(git count-objects | sed "s/ .*//") &&
! test -f $BLOB_FILE
@@ -53,11 +53,11 @@ test_expect_success 'gc: implicit prune --expire' '
BLOB_FILE=.git/objects/$(echo $BLOB | sed "s/^../&\//") &&
test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
test -f $BLOB_FILE &&
- test-chmtime -$((86400*14-30)) $BLOB_FILE &&
+ ~/git-repo/test-chmtime -$((86400*14-30)) $BLOB_FILE &&
git gc &&
test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
test -f $BLOB_FILE &&
- test-chmtime -$((86400*14+1)) $BLOB_FILE &&
+ ~/git-repo/test-chmtime -$((86400*14+1)) $BLOB_FILE &&
git gc &&
test $before = $(git count-objects | sed "s/ .*//") &&
! test -f $BLOB_FILE
diff --git a/t/test-lib.sh b/t/test-lib.sh
index c861141..38e6a59 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -345,7 +345,7 @@ test_create_repo () {
repo="$1"
mkdir "$repo"
cd "$repo" || error "Cannot setup test environment"
- "$GIT_EXEC_PATH/git" init "--template=$GIT_EXEC_PATH/templates/blt/" >/dev/null 2>&1 ||
+ "git" init >/dev/null 2>&1 ||
error "cannot run git init -- have you built things yet?"
mv .git/hooks .git/hooks-disabled
cd "$owd"
@@ -387,20 +387,25 @@ test_done () {
# Test the binaries we have just built. The tests are kept in
# t/ subdirectory and are run in 'trash directory' subdirectory.
-PATH=$(pwd)/..:$PATH
-GIT_EXEC_PATH=$(pwd)/..
-GIT_TEMPLATE_DIR=$(pwd)/../templates/blt
-unset GIT_CONFIG
-unset GIT_CONFIG_LOCAL
-GIT_CONFIG_NOSYSTEM=1
-GIT_CONFIG_NOGLOBAL=1
-export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_CONFIG_NOGLOBAL
-
-GITPERLLIB=$(pwd)/../perl/blib/lib:$(pwd)/../perl/blib/arch/auto/Git
-export GITPERLLIB
-test -d ../templates/blt || {
- error "You haven't built things yet, have you?"
-}
+if false; then
+ PATH=$(pwd)/..:$PATH
+ GIT_EXEC_PATH=$(pwd)/..
+ GIT_TEMPLATE_DIR=$(pwd)/../templates/blt
+
+ GITPERLLIB=$(pwd)/../perl/blib/lib:$(pwd)/../perl/blib/arch/auto/Git
+ export GITPERLLIB
+ test -d ../templates/blt || {
+ error "You haven't built things yet, have you?"
+ }
+
+ . ../GIT-BUILD-OPTIONS
+fi
+
+ unset GIT_CONFIG
+ unset GIT_CONFIG_LOCAL
+ GIT_CONFIG_NOSYSTEM=1
+ GIT_CONFIG_NOGLOBAL=1
+ export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_CONFIG_NOGLOBAL
if ! test -x ../test-chmtime; then
echo >&2 'You need to build test-chmtime:'
@@ -408,8 +413,6 @@ if ! test -x ../test-chmtime; then
exit 1
fi
-. ../GIT-BUILD-OPTIONS
-
# Test repository
test="trash directory"
rm -fr "$test" || {
^ permalink raw reply related
* [PATCH] builtin-merge: refresh the index before calling a strategy
From: Miklos Vajna @ 2008-10-03 13:02 UTC (permalink / raw)
To: Thomas Rast; +Cc: spearce, msoulier, git
In-Reply-To: <20080928151135.GF23137@genesis.frugalware.org>
In case a file is touched but has no real changes then we just have to
update the index and should not error out.
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---
On Sun, Sep 28, 2008 at 05:11:35PM +0200, Miklos Vajna <vmiklos@frugalware.org> wrote:
> Thanks for the reproducer, I'll write a proper testcase for this and
> try to
> provide a fix for it as well.
Try this one.
builtin-merge.c | 10 ++++++++++
t/t7600-merge.sh | 9 +++++++++
2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/builtin-merge.c b/builtin-merge.c
index 4c9ed5d..6c9dfe6 100644
--- a/builtin-merge.c
+++ b/builtin-merge.c
@@ -548,6 +548,16 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
int i = 0, ret;
struct commit_list *j;
struct strbuf buf;
+ int index_fd;
+ struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
+
+ index_fd = hold_locked_index(lock, 1);
+ refresh_cache(REFRESH_QUIET);
+ if (active_cache_changed &&
+ (write_cache(index_fd, active_cache, active_nr) ||
+ commit_locked_index(lock)))
+ return error("Unable to write index.");
+ rollback_lock_file(lock);
if (!strcmp(strategy, "recursive") || !strcmp(strategy, "subtree")) {
int clean;
diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
index 98cfc53..61db3c3 100755
--- a/t/t7600-merge.sh
+++ b/t/t7600-merge.sh
@@ -520,4 +520,13 @@ test_expect_success 'merge --no-ff --no-commit && commit' '
test_debug 'gitk --all'
+test_expect_success 'refresh the index before merging' '
+ git reset --hard c1 &&
+ sleep 1 &&
+ touch file &&
+ git merge c3
+'
+
+test_debug 'gitk --all'
+
test_done
--
1.6.0.2
^ permalink raw reply related
* Re: Numeric Revision Names?
From: Bruce Stephens @ 2008-10-03 12:44 UTC (permalink / raw)
To: marceloribeiro; +Cc: git
In-Reply-To: <19796862.post@talk.nabble.com>
marceloribeiro <marcelo@sonnay.com> writes:
[...]
> Is there any way to configure it to start a projects revisions on
> lets say, revision 0, and keep incrementing it after each commit?
No.
[...]
(There's no such numbering system that would work entirely
satisfactorily in a distributed system. Some systems have numbering
schemes that are perhaps easier to use (at least for some purposes)
than the underlying hashes, but no such scheme is used in git.)
^ permalink raw reply
* Re: Numeric Revision Names?
From: Robin Burchell @ 2008-10-03 12:41 UTC (permalink / raw)
To: marceloribeiro; +Cc: git
In-Reply-To: <19796862.post@talk.nabble.com>
This can be emulated to some extent by using git tag, and git describe
--tags. I can't remember specifics off the top of my head though, it's
a while since I set that up.
On Fri, Oct 3, 2008 at 1:37 PM, marceloribeiro <marcelo@sonnay.com> wrote:
>
> Hi,
>
> I am new to git, and my question may be stupid, but anyway...
> I am used to the numeric revision names on svn, and on Git
> all I get are hexadecimal names.
>
> Is there any way to configure it to start a projects revisions on
> lets say, revision 0, and keep incrementing it after each commit?
>
> I tried finding it on git doc but wasnt able to. Maybe I am missing
> something....
>
> Thanks in advance!
> --
> View this message in context: http://www.nabble.com/Numeric-Revision-Names--tp19796862p19796862.html
> Sent from the git mailing list archive at Nabble.com.
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply
* Numeric Revision Names?
From: marceloribeiro @ 2008-10-03 12:37 UTC (permalink / raw)
To: git
Hi,
I am new to git, and my question may be stupid, but anyway...
I am used to the numeric revision names on svn, and on Git
all I get are hexadecimal names.
Is there any way to configure it to start a projects revisions on
lets say, revision 0, and keep incrementing it after each commit?
I tried finding it on git doc but wasnt able to. Maybe I am missing
something....
Thanks in advance!
--
View this message in context: http://www.nabble.com/Numeric-Revision-Names--tp19796862p19796862.html
Sent from the git mailing list archive at Nabble.com.
^ permalink raw reply
* [FYI][PATCH] Customizing the WinGit installer
From: Petr Baudis @ 2008-10-03 12:27 UTC (permalink / raw)
To: msysgit; +Cc: git
This patch is intended just as a FYI example on customizing the WinGit
installer for e.g. corporate deployment or similar needs, as a starting
point in case anyone needs to do that.
This patch removes some steps redundant for our usage scenario (choose
of the $PATH mode, showing release notes), slightly customizes the
default Git configuration and changes the quickstart icon from Git Bash
to Git GUI (this one might be worth considering for upstream too,
especially after stock git-gui gains the remotes management support).
Signed-off-by: Petr Baudis <petr.baudis@novartis.com>
---
diff --git a/etc/gitconfig b/etc/gitconfig
index 251088c..d0e8e53 100644
--- a/etc/gitconfig
+++ b/etc/gitconfig
@@ -5,3 +5,12 @@
diff = auto
[pack]
packSizeLimit = 2g
+[locator "Server"]
+ template = M:/public_git/%s
+[locator "Library"]
+ template = git://lib.example.com/%s
+[gui]
+ remotelocator = Server
+ pulllocator = Library
+ pushlocator = Server
+ autoexplore = true
diff --git a/share/WinGit/install.iss b/share/WinGit/install.iss
index 0f0514d..05fdae6 100644
--- a/share/WinGit/install.iss
+++ b/share/WinGit/install.iss
@@ -20,7 +20,7 @@ ChangesEnvironment=yes
DefaultDirName={pf}\{#emit APP_NAME}
DefaultGroupName={#emit APP_NAME}
DisableReadyPage=yes
-InfoBeforeFile=gpl-2.0.rtf
+;InfoBeforeFile=gpl-2.0.rtf
PrivilegesRequired=none
UninstallDisplayIcon=etc\git.ico
@@ -36,13 +36,13 @@ Name: guiextension; Description: "Add ""Git &GUI Here"""; GroupDescription: "Win
[Files]
Source: "*"; DestDir: "{app}"; Excludes: "\*.bmp, gpl-2.0.rtf, \install.*, \tmp.*, \bin\*install*"; Flags: recursesubdirs
-Source: ReleaseNotes.rtf; DestDir: "{app}"; Flags: isreadme
+;Source: ReleaseNotes.rtf; DestDir: "{app}"; Flags: isreadme
[Icons]
Name: "{group}\Git GUI"; Filename: "{app}\bin\wish.exe"; Parameters: """{app}\bin\git-gui"""; WorkingDir: "%USERPROFILE%"; IconFilename: "{app}\etc\git.ico"
Name: "{group}\Git Bash"; Filename: "{syswow64}\cmd.exe"; Parameters: "/c """"{app}\bin\sh.exe"" --login -i"""; WorkingDir: "%USERPROFILE%"; IconFilename: "{app}\etc\git.ico"
Name: "{group}\Uninstall Git"; Filename: "{uninstallexe}"
-Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\Git Bash"; Filename: "{syswow64}\cmd.exe"; Parameters: "/c """"{app}\bin\sh.exe"" --login -i"""; WorkingDir: "%USERPROFILE%"; IconFilename: "{app}\etc\git.ico"; Tasks: quicklaunchicon
+Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\Git GUI"; Filename: "{app}\bin\wish.exe"; Parameters: """{app}\bin\git-gui"""; WorkingDir: "%USERPROFILE%"; IconFilename: "{app}\etc\git.ico"; Tasks: quicklaunchicon
Name: "{code:GetShellFolder|desktop}\Git Bash"; Filename: "{syswow64}\cmd.exe"; Parameters: "/c """"{app}\bin\sh.exe"" --login -i"""; WorkingDir: "%USERPROFILE%"; IconFilename: "{app}\etc\git.ico"; Tasks: desktopicon
[Messages]
@@ -171,8 +171,7 @@ begin
end;
var
- EnvPage,PuTTYPage:TWizardPage;
- RdbGitBash,RdbGitCmd,RdbGitCmdTools:TRadioButton;
+ PuTTYPage:TWizardPage;
RdbOpenSSH,RdbPLink:TRadioButton;
EdtPLink:TEdit;
@@ -197,105 +196,12 @@ end;
procedure InitializeWizard;
var
- LblGitBash,LblGitCmd,LblGitCmdTools,LblGitCmdToolsWarn:TLabel;
LblOpenSSH,LblPLink:TLabel;
BtnPLink:TButton;
begin
- // Create a custom page for modifying the environment.
- EnvPage:=CreateCustomPage(
- wpSelectTasks,
- 'Adjusting your PATH environment',
- 'How would you like to use Git from the command line?'
- );
-
- // 1st choice
- RdbGitBash:=TRadioButton.Create(EnvPage);
- with RdbGitBash do begin
- Parent:=EnvPage.Surface;
- Caption:='Use Git Bash only';
- Left:=ScaleX(4);
- Top:=ScaleY(8);
- Width:=ScaleX(129);
- Height:=ScaleY(17);
- Font.Style:=[fsBold];
- TabOrder:=0;
- Checked:=True;
- end;
- LblGitBash:=TLabel.Create(EnvPage);
- with LblGitBash do begin
- Parent:=EnvPage.Surface;
- Caption:=
- 'This is the most conservative choice if you are concerned about the stability' + #13 +
- 'of your system. Your PATH will not be modified.';
- Left:=ScaleX(28);
- Top:=ScaleY(32);
- Width:=ScaleX(405);
- Height:=ScaleY(26);
- end;
-
- // 2nd choice
- RdbGitCmd:=TRadioButton.Create(EnvPage);
- with RdbGitCmd do begin
- Parent:=EnvPage.Surface;
- Caption:='Run Git from the Windows Command Prompt';
- Left:=ScaleX(4);
- Top:=ScaleY(76);
- Width:=ScaleX(281);
- Height:=ScaleY(17);
- Font.Style:=[fsBold];
- TabOrder:=1;
- end;
- LblGitCmd:=TLabel.Create(EnvPage);
- with LblGitCmd do begin
- Parent:=EnvPage.Surface;
- Caption:=
- 'This option is considered safe and no conflicts with other tools are known.' + #13 +
- 'Only Git will be added to your PATH. Use this option if you want to use Git' + #13 +
- 'from a Cygwin Prompt (make sure to not have Cygwin''s Git installed).';
- Left:=ScaleX(28);
- Top:=ScaleY(100);
- Width:=ScaleX(405);
- Height:=ScaleY(39);
- end;
-
- // 3rd choice
- RdbGitCmdTools:=TRadioButton.Create(EnvPage);
- with RdbGitCmdTools do begin
- Parent:=EnvPage.Surface;
- Caption:='Run Git and included Unix tools from the Windows Command Prompt';
- Left:=ScaleX(4);
- Top:=ScaleY(152);
- Width:=ScaleX(405);
- Height:=ScaleY(17);
- Font.Style:=[fsBold];
- TabOrder:=2;
- end;
- LblGitCmdTools:=TLabel.Create(EnvPage);
- with LblGitCmdTools do begin
- Parent:=EnvPage.Surface;
- Caption:='Both Git and its accompanying Unix tools will be added to your PATH.';
- Left:=ScaleX(28);
- Top:=ScaleY(176);
- Width:=ScaleX(405);
- Height:=ScaleY(13);
- end;
- LblGitCmdToolsWarn:=TLabel.Create(EnvPage);
- with LblGitCmdToolsWarn do begin
- Parent:=EnvPage.Surface;
- Caption:=
- 'Warning: This will override Windows tools like find.exe and' + #13 +
- 'sort.exe. Select this option only if you understand the implications.';
- Left:=ScaleX(28);
- Top:=ScaleY(192);
- Width:=ScaleX(376);
- Height:=ScaleY(26);
- Font.Color:=255;
- Font.Style:=[fsBold];
- end;
-
// Create a custom page for using PuTTY's plink instead of ssh.
PuTTYPage:=CreateCustomPage(
- EnvPage.ID,
+ wpSelectTasks,
'Choosing the SSH executable',
'Which Secure Shell client program would you like Git to use?'
);
@@ -537,45 +443,6 @@ begin
end;
end;
- // Modify the PATH variable as requested by the user.
- if RdbGitCmd.Checked or RdbGitCmdTools.Checked then begin
- i:=GetArrayLength(EnvPath);
- SetArrayLength(EnvPath,i+1);
-
- // List \cmd before \bin so \cmd has higher priority and programs in
- // there will be called in favor of those in \bin.
- EnvPath[i]:=ExpandConstant('{app}\cmd');
-
- if RdbGitCmdTools.Checked then begin
- SetArrayLength(EnvPath,i+2);
- EnvPath[i+1]:=ExpandConstant('{app}\bin');
-
- // Set HOME for the Windows Command Prompt, but only if it has not been set manually before.
- EnvHome:=GetEnvStrings('HOME',IsAdminLoggedOn);
- i:=GetArrayLength(EnvHome);
- if (i=0) or ((i=1) and (Length(EnvHome[0])=0)) then begin
- SetArrayLength(EnvHome,1);
- EnvHome[0]:=ExpandConstant('{%USERPROFILE}');
- if not SetEnvStrings('HOME',IsAdminLoggedOn,True,EnvHome) then begin
- Msg:='Line {#emit __LINE__}: Unable to set the HOME environment variable.';
- MsgBox(Msg,mbError,MB_OK);
- Log(Msg);
- // This is not a critical error, the user can probably fix it manually,
- // so we continue.
- end;
-
- // Mark that we have changed HOME.
- if not SetIniString('Environment','HOME',EnvHome[0],FileName) then begin
- Msg:='Line {#emit __LINE__}: Unable to write to file "'+FileName+'".';
- MsgBox(Msg,mbError,MB_OK);
- Log(Msg);
- // This is not a critical error, though uninstall / reinstall will probably not run cleanly,
- // so we continue.
- end;
- end;
- end;
- end;
-
// Set the current user's PATH directories.
if not SetEnvStrings('PATH',IsAdminLoggedOn,True,EnvPath) then begin
Msg:='Line {#emit __LINE__}: Unable to set the PATH environment variable.';
^ permalink raw reply related
* [PATCH] Associate 'git gui clone' with the git:// protocol
From: Petr Baudis @ 2008-10-03 12:19 UTC (permalink / raw)
To: msysgit; +Cc: git
This MSysGit patch makes the installer register 'git gui clone'
as the Git URL protocol handler. This depends on the 'git gui clone'
functionality itself, of course - currently in the process of getting
accepted upstream (hopefully).
Signed-off-by: Petr Baudis <petr.baudis@novartis.com>
---
Sorry if the line offsets are a bit off.
diff --git a/share/WinGit/install.iss b/share/WinGit/install.iss
index 05fdae6..82e8ecf 100644
--- a/share/WinGit/install.iss
+++ b/share/WinGit/install.iss
@@ -484,6 +484,16 @@ begin
// so we continue.
end;
end;
+
+ if (not RegWriteStringValue(HKEY_CLASSES_ROOT,'git','','URL:Git Protocol'))
+ or (not RegWriteStringValue(HKEY_CLASSES_ROOT,'git','URL Protocol',''))
+ or (not RegWriteStringValue(HKEY_CLASSES_ROOT,'git\shell\open\command','','"'+AppDir+'\bin\wish.exe" "'+AppDir+'\bin\git-gui" "clone" "%1"')) then begin
+ Msg:='Line {#emit __LINE__}: Unable to set up the "git://" URL protocol handler.';
+ MsgBox(Msg,mbError,MB_OK);
+ Log(Msg);
+ // This is not a critical error, the user can probably fix it manually,
+ // so we continue.
+ end;
end;
{
^ permalink raw reply related
* [PATCH] builtin-commit: avoid always using reduce_heads()
From: Miklos Vajna @ 2008-10-03 12:04 UTC (permalink / raw)
To: spearce; +Cc: SZEDER Gabor, jnareb, Johannes.Schindelin, git
In-Reply-To: <20081003023518.GA3291@spearce.org>
In case git merge --no-ff is used with --no-commit or we have a
conflict, write info about if fast forwards are allowed or not to
$GIT_DIR/MERGE_MODE.
Based on this info, don't run reduce_heads() in case fast-forwards are
denied, to avoid turning a 'merge --no-ff' to a non-merge commit.
Test case by SZEDER Gabor <szeder@ira.uka.de>
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---
On Thu, Oct 02, 2008 at 07:35:18PM -0700, "Shawn O. Pearce" <spearce@spearce.org> wrote:
> > + unlink(git_path("MERGE_MODE"));
> > unlink(git_path("SQUASH_MSG"));
> >
> > if (commit_index_files())
>
> Hmmph. Should branch.c and builtin-reset.c clean this new file
> up too?
Right, I added it to branch.c::remove_branch_state() and
builtin-merge.c::drop_save(). I don't think I should touch
builtin-reset.c, it does not delete MERGE_HEAD/MERGE_MSG either.
> > + fd = open(git_path("MERGE_MODE"), O_WRONLY | O_CREAT,
> > 0666);
> > + if (fd < 0)
> > + die("Could open %s for writing",
> > git_path("MERGE_MODE"));
> > + strbuf_reset(&buf);
> > + if (!allow_fast_forward)
> > + strbuf_addf(&buf, "no-ff");
> > + if (write_in_full(fd, buf.buf, buf.len) != buf.len)
>
> Shouldn't we open this file with O_TRUNC to avoid this scenario:
>
> $ git merge --no-ff --no-commit foo
> $ git reset --hard
> $ git merge --no-commit foo
> ... *sigh* MERGE_MODE still has "no-ff" in it ...
>
> This is especially true since some porcelain (e.g. git-gui) just
> deletes MERGE_HEAD right now and doesn't know about cleaning up
> MERGE_MODE. We'd want to at least reset it correctly on the next
> invocation to git-merge.
Fixed.
branch.c | 1 +
builtin-commit.c | 13 ++++++++++++-
builtin-merge.c | 10 ++++++++++
t/t7600-merge.sh | 9 +++++++++
4 files changed, 32 insertions(+), 1 deletions(-)
diff --git a/branch.c b/branch.c
index b1e59f2..205b89d 100644
--- a/branch.c
+++ b/branch.c
@@ -168,5 +168,6 @@ void remove_branch_state(void)
unlink(git_path("MERGE_HEAD"));
unlink(git_path("MERGE_RR"));
unlink(git_path("MERGE_MSG"));
+ unlink(git_path("MERGE_MODE"));
unlink(git_path("SQUASH_MSG"));
}
diff --git a/builtin-commit.c b/builtin-commit.c
index 55e1087..f546cf7 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -937,6 +937,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
unsigned char commit_sha1[20];
struct ref_lock *ref_lock;
struct commit_list *parents = NULL, **pptr = &parents;
+ struct stat statbuf;
+ int allow_fast_forward = 1;
git_config(git_commit_config, NULL);
@@ -988,7 +990,15 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
reflog_msg = "commit";
pptr = &commit_list_insert(lookup_commit(head_sha1), pptr)->next;
}
- parents = reduce_heads(parents);
+ strbuf_reset(&sb);
+ if (!stat(git_path("MERGE_MODE"), &statbuf)) {
+ if (strbuf_read_file(&sb, git_path("MERGE_MODE"), 0) < 0)
+ die("could not read MERGE_MODE: %s", strerror(errno));
+ if (!strcmp(sb.buf, "no-ff"))
+ allow_fast_forward = 0;
+ }
+ if (allow_fast_forward)
+ parents = reduce_heads(parents);
/* Finally, get the commit message */
strbuf_init(&sb, 0);
@@ -1040,6 +1050,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
unlink(git_path("MERGE_HEAD"));
unlink(git_path("MERGE_MSG"));
+ unlink(git_path("MERGE_MODE"));
unlink(git_path("SQUASH_MSG"));
if (commit_index_files())
diff --git a/builtin-merge.c b/builtin-merge.c
index 5c65a58..4c9ed5d 100644
--- a/builtin-merge.c
+++ b/builtin-merge.c
@@ -180,6 +180,7 @@ static void drop_save(void)
{
unlink(git_path("MERGE_HEAD"));
unlink(git_path("MERGE_MSG"));
+ unlink(git_path("MERGE_MODE"));
}
static void save_state(void)
@@ -1210,6 +1211,15 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
merge_msg.len)
die("Could not write to %s", git_path("MERGE_MSG"));
close(fd);
+ fd = open(git_path("MERGE_MODE"), O_WRONLY | O_CREAT | O_TRUNC, 0666);
+ if (fd < 0)
+ die("Could open %s for writing", git_path("MERGE_MODE"));
+ strbuf_reset(&buf);
+ if (!allow_fast_forward)
+ strbuf_addf(&buf, "no-ff");
+ if (write_in_full(fd, buf.buf, buf.len) != buf.len)
+ die("Could not write to %s", git_path("MERGE_MODE"));
+ close(fd);
}
if (merge_was_ok) {
diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
index 9516f54..98cfc53 100755
--- a/t/t7600-merge.sh
+++ b/t/t7600-merge.sh
@@ -511,4 +511,13 @@ test_expect_success 'in-index merge' '
test_debug 'gitk --all'
+test_expect_success 'merge --no-ff --no-commit && commit' '
+ git reset --hard c0 &&
+ git merge --no-ff --no-commit c1 &&
+ EDITOR=: git commit &&
+ verify_parents $c0 $c1
+'
+
+test_debug 'gitk --all'
+
test_done
--
1.6.0.2
^ 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