Skip to content

Commit

Permalink
Merge master into aw/mirror-push
Browse files Browse the repository at this point in the history
  • Loading branch information
Junio C Hamano committed Nov 10, 2007
2 parents 1496553 + c238dad commit 0d9d89f
Show file tree
Hide file tree
Showing 82 changed files with 2,182 additions and 1,165 deletions.
112 changes: 112 additions & 0 deletions Documentation/CodingGuidelines
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
Like other projects, we also have some guidelines to keep to the
code. For git in general, three rough rules are:

- Most importantly, we never say "It's in POSIX; we'll happily
ignore your needs should your system not conform to it."
We live in the real world.

- However, we often say "Let's stay away from that construct,
it's not even in POSIX".

- In spite of the above two rules, we sometimes say "Although
this is not in POSIX, it (is so convenient | makes the code
much more readable | has other good characteristics) and
practically all the platforms we care about support it, so
let's use it".

Again, we live in the real world, and it is sometimes a
judgement call, the decision based more on real world
constraints people face than what the paper standard says.


As for more concrete guidelines, just imitate the existing code
(this is a good guideline, no matter which project you are
contributing to). But if you must have a list of rules,
here they are.

For shell scripts specifically (not exhaustive):

- We prefer $( ... ) for command substitution; unlike ``, it
properly nests. It should have been the way Bourne spelled
it from day one, but unfortunately isn't.

- We use ${parameter-word} and its [-=?+] siblings, and their
colon'ed "unset or null" form.

- We use ${parameter#word} and its [#%] siblings, and their
doubled "longest matching" form.

- We use Arithmetic Expansion $(( ... )).

- No "Substring Expansion" ${parameter:offset:length}.

- No shell arrays.

- No strlen ${#parameter}.

- No regexp ${parameter/pattern/string}.

- We do not use Process Substitution <(list) or >(list).

- We prefer "test" over "[ ... ]".

- We do not write the noiseword "function" in front of shell
functions.

For C programs:

- We use tabs to indent, and interpret tabs as taking up to
8 spaces.

- We try to keep to at most 80 characters per line.

- When declaring pointers, the star sides with the variable
name, i.e. "char *string", not "char* string" or
"char * string". This makes it easier to understand code
like "char *string, c;".

- We avoid using braces unnecessarily. I.e.

if (bla) {
x = 1;
}

is frowned upon. A gray area is when the statement extends
over a few lines, and/or you have a lengthy comment atop of
it. Also, like in the Linux kernel, if there is a long list
of "else if" statements, it can make sense to add braces to
single line blocks.

- Try to make your code understandable. You may put comments
in, but comments invariably tend to stale out when the code
they were describing changes. Often splitting a function
into two makes the intention of the code much clearer.

- Double negation is often harder to understand than no negation
at all.

- Some clever tricks, like using the !! operator with arithmetic
constructs, can be extremely confusing to others. Avoid them,
unless there is a compelling reason to use them.

- Use the API. No, really. We have a strbuf (variable length
string), several arrays with the ALLOC_GROW() macro, a
path_list for sorted string lists, a hash map (mapping struct
objects) named "struct decorate", amongst other things.

- When you come up with an API, document it.

- The first #include in C files, except in platform specific
compat/ implementations, should be git-compat-util.h or another
header file that includes it, such as cache.h or builtin.h.

- If you are planning a new command, consider writing it in shell
or perl first, so that changes in semantics can be easily
changed and discussed. Many git commands started out like
that, and a few are still scripts.

- Avoid introducing a new dependency into git. This means you
usually should stay away from scripting languages not already
used in the git core command set (unless your command is clearly
separate from it, such as an importer to convert random-scm-X
repositories to git).
6 changes: 3 additions & 3 deletions Documentation/RelNotes-1.5.3.5.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ Fixes since v1.5.3.4

* Git segfaulted when reading an invalid .gitattributes file. Fixed.

* post-receive-email example hook fixed was fixed for
non-fast-forward updates.
* post-receive-email example hook was fixed for non-fast-forward
updates.

* Documentation updates for supported (but previously undocumented)
options of "git-archive" and "git-reflog".
Expand All @@ -90,5 +90,5 @@ Fixes since v1.5.3.4
* "git-send-pack $remote frotz" segfaulted when there is nothing
named 'frotz' on the local end.

* "git-rebase -interactive" did not handle its "--strategy" option
* "git-rebase --interactive" did not handle its "--strategy" option
properly.
21 changes: 21 additions & 0 deletions Documentation/RelNotes-1.5.3.6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
GIT v1.5.3.6 Release Notes
==========================

Fixes since v1.5.3.5
--------------------

* git-cvsexportcommit handles root commits better;

* git-svn dcommit used to clobber when sending a series of
patches;

* git-grep sometimes refused to work when your index was
unmerged;

* Quite a lot of documentation clarifications.

--
exec >/var/tmp/1
O=v1.5.3.5-32-gcb6c162
echo O=`git describe refs/heads/maint`
git shortlog --no-merges $O..refs/heads/maint
29 changes: 27 additions & 2 deletions Documentation/RelNotes-1.5.4.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ Updates since v1.5.3

* Comes with much improved gitk.

* git-reset is now built-in.
* "progress display" from many commands are a lot nicer to the
eye. Transfer commands show throughput data.

* git-reset is now built-in and its output can be squelched with -q.

* git-send-email can optionally talk over ssmtp and use SMTP-AUTH.

Expand Down Expand Up @@ -46,6 +49,28 @@ Updates since v1.5.3

* Various Perforce importer updates.

* git-lost-found was deprecated in favor of git-fsck's --lost-found
option.

* git-svnimport was removed in favor of git-svn.

* git-bisect learned "skip" action to mark untestable commits.

* rename detection diff family, while detecting exact matches,
has been greatly optimized.

* Example update and post-receive hooks have been improved.

* In addition there are quite a few internal clean-ups. Notably

- many fork/exec have been replaced with run-command API,
brought from the msysgit effort.

- introduction and more use of the option parser API.

- enhancement and more use of the strbuf API.


Fixes since v1.5.3
------------------

Expand All @@ -54,6 +79,6 @@ this release, unless otherwise noted.

--
exec >/var/tmp/1
O=v1.5.3.4-450-g952a9e5
O=v1.5.3.5-618-g5d4138a
echo O=`git describe refs/heads/master`
git shortlog --no-merges $O..refs/heads/master ^refs/heads/maint
9 changes: 4 additions & 5 deletions Documentation/SubmittingPatches
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ Checklist (and a short version for the impatient):
Patch:

- use "git format-patch -M" to create the patch
- send your patch to <git@vger.kernel.org>. If you use
git-send-email(1), please test it first by sending
email to yourself.
- do not PGP sign your patch
- do not attach your patch, but read in the mail
body, unless you cannot teach your mailer to
Expand All @@ -31,13 +28,15 @@ Checklist (and a short version for the impatient):
corrupt whitespaces.
- provide additional information (which is unsuitable for
the commit message) between the "---" and the diffstat
- send the patch to the list (git@vger.kernel.org) and the
maintainer (gitster@pobox.com).
- if you change, add, or remove a command line option or
make some other user interface change, the associated
documentation should be updated as well.
- if your name is not writable in ASCII, make sure that
you send off a message in the correct encoding.
- send the patch to the list (git@vger.kernel.org) and the
maintainer (gitster@pobox.com). If you use
git-send-email(1), please test it first by sending
email to yourself.

Long version:

Expand Down
13 changes: 11 additions & 2 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,8 @@ branch.<name>.mergeoptions::
supported.

clean.requireForce::
A boolean to make git-clean do nothing unless given -f or -n. Defaults
to false.
A boolean to make git-clean do nothing unless given -f
or -n. Defaults to true.

color.branch::
A boolean to enable/disable color in the output of
Expand Down Expand Up @@ -661,6 +661,15 @@ pack.threads::
machines. The required amount of memory for the delta search window
is however multiplied by the number of threads.

pack.indexVersion::
Specify the default pack index version. Valid values are 1 for
legacy pack index used by Git versions prior to 1.5.2, and 2 for
the new pack index with capabilities for packs larger than 4 GB
as well as proper protection against the repacking of corrupted
packs. Version 2 is selected and this config option ignored
whenever the corresponding pack is larger than 2 GB. Otherwise
the default is 1.

pull.octopus::
The default merge strategy to use when pulling multiple branches
at once.
Expand Down
9 changes: 8 additions & 1 deletion Documentation/git-cherry-pick.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ git-cherry-pick - Apply the change introduced by an existing commit

SYNOPSIS
--------
'git-cherry-pick' [--edit] [-n] [-x] <commit>
'git-cherry-pick' [--edit] [-n] [-m parent-number] [-x] <commit>

DESCRIPTION
-----------
Expand Down Expand Up @@ -44,6 +44,13 @@ OPTIONS
described above, and `-r` was to disable it. Now the
default is not to do `-x` so this option is a no-op.

-m parent-number|--mainline parent-number::
Usually you cannot revert a merge because you do not know which
side of the merge should be considered the mainline. This
option specifies the parent number (starting from 1) of
the mainline and allows cherry-pick to replay the change
relative to the specified parent.

-n|--no-commit::
Usually the command automatically creates a commit with
a commit log message stating which commit was
Expand Down
2 changes: 1 addition & 1 deletion Documentation/git-clone.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SYNOPSIS
'git-clone' [--template=<template_directory>]
[-l] [-s] [--no-hardlinks] [-q] [-n] [--bare]
[-o <name>] [-u <upload-pack>] [--reference <repository>]
[--depth <depth>] <repository> [<directory>]
[--depth <depth>] [--] <repository> [<directory>]

DESCRIPTION
-----------
Expand Down
4 changes: 4 additions & 0 deletions Documentation/git-lost-found.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ SYNOPSIS

DESCRIPTION
-----------

*NOTE*: this command is deprecated. Use gitlink:git-fsck[1] with
the option '--lost-found' instead.

Finds dangling commits and tags from the object database, and
creates refs to them in the .git/lost-found/ directory. Commits and
tags that dereference to commits are stored in .git/lost-found/commit,
Expand Down
7 changes: 5 additions & 2 deletions Documentation/git-reset.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ git-reset - Reset current HEAD to the specified state
SYNOPSIS
--------
[verse]
'git-reset' [--mixed | --soft | --hard] [<commit>]
'git-reset' [--mixed] <commit> [--] <paths>...
'git-reset' [--mixed | --soft | --hard] [-q] [<commit>]
'git-reset' [--mixed] [-q] <commit> [--] <paths>...

DESCRIPTION
-----------
Expand Down Expand Up @@ -45,6 +45,9 @@ OPTIONS
switched to. Any changes to tracked files in the working tree
since <commit> are lost.

-q::
Be quiet, only report errors.

<commit>::
Commit to make the current HEAD.

Expand Down
9 changes: 8 additions & 1 deletion Documentation/git-revert.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ git-revert - Revert an existing commit

SYNOPSIS
--------
'git-revert' [--edit | --no-edit] [-n] <commit>
'git-revert' [--edit | --no-edit] [-n] [-m parent-number] <commit>

DESCRIPTION
-----------
Expand All @@ -27,6 +27,13 @@ OPTIONS
message prior committing the revert. This is the default if
you run the command from a terminal.

-m parent-number|--mainline parent-number::
Usually you cannot revert a merge because you do not know which
side of the merge should be considered the mainline. This
option specifies the parent number (starting from 1) of
the mainline and allows revert to reverse the change
relative to the specified parent.

--no-edit::
With this option, `git-revert` will not start the commit
message editor.
Expand Down
3 changes: 1 addition & 2 deletions Documentation/git-send-email.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ The --cc option must be repeated for each user you want on the cc list.
is not set, this will be prompted for.

--suppress-from, --no-suppress-from::
If this is set, do not add the From: address to the cc: list, if it
shows up in a From: line.
If this is set, do not add the From: address to the cc: list.
Default is the value of 'sendemail.suppressfrom' configuration value;
if that is unspecified, default to --no-suppress-from.

Expand Down
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ all::
# Define OLD_ICONV if your library has an old iconv(), where the second
# (input buffer pointer) parameter is declared with type (const char **).
#
# Define NO_DEFLATE_BOUND if your zlib does not have deflateBound.
#
# Define NO_R_TO_GCC_LINKER if your gcc does not like "-R/path/lib"
# that tells runtime paths to dynamic libraries;
# "-Wl,-rpath=/path/lib" is used instead.
Expand Down Expand Up @@ -298,7 +300,7 @@ DIFF_OBJS = \
LIB_OBJS = \
blob.o commit.o connect.o csum-file.o cache-tree.o base85.o \
date.o diff-delta.o entry.o exec_cmd.o ident.o \
interpolate.o hash.o \
pretty.o interpolate.o hash.o \
lockfile.o \
patch-ids.o \
object.o pack-check.o pack-write.o patch-delta.o path.o pkt-line.o \
Expand Down Expand Up @@ -662,6 +664,10 @@ ifdef OLD_ICONV
BASIC_CFLAGS += -DOLD_ICONV
endif

ifdef NO_DEFLATE_BOUND
BASIC_CFLAGS += -DNO_DEFLATE_BOUND
endif

ifdef PPC_SHA1
SHA1_HEADER = "ppc/sha1.h"
LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
Expand Down Expand Up @@ -917,6 +923,7 @@ git-http-push$X: revision.o http.o http-push.o $(GITLIBS)

$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
$(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
builtin-revert.o builtin-runstatus.o wt-status.o: wt-status.h

$(LIB_FILE): $(LIB_OBJS)
$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
Expand Down
Loading

0 comments on commit 0d9d89f

Please sign in to comment.