Commit Graph

76 Commits (master)

Author SHA1 Message Date
Christian Hesse 779631c6dc global: replace references to 'sha1' with 'oid'
For some time now sha1 is considered broken and upstream is working to
replace it with sha256. Replace all references to 'sha1' with 'oid',
just as upstream does.

Signed-off-by: Christian Hesse <mail@eworm.de>
4 years ago
Jason A. Donenfeld 6a8d6d4b50 global: use proper accessors for maybe_tree
A previous commit changed ->tree to ->maybe_tree throughout, which may
have worked at the time, but wasn't safe, because maybe_tree is loaded
lazily. This manifested itself in crashes when using the "follow" log
feature. The proper fix is to use the correct contextual accessors
everytime we want access to maybe_tree. Thankfully, the commit.cocci
script takes care of creating mostly-correct patches that we could then
fix up, resulting in this commit here.

Fixes: 255b78f ("git: update to v2.18.0")
Reviewed-by: Christian Hesse <mail@eworm.de>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
4 years ago
Chris Mayo bd0293f570 ui-diff,ui-tag: don't use htmlf with non-formatted strings
Signed-off-by: Chris Mayo <aklhfex@gmail.com>
5 years ago
Christian Hesse 2c9f56f3e1 git: update to v2.19.1
Update to git version v2.19.1. Required changes follow upstream commits:

* commit: add repository argument to get_cached_commit_buffer
  (3ce85f7e5a41116145179f0fae2ce6d86558d099)

* commit: add repository argument to lookup_commit_reference
  (2122f6754c93be8f02bfb5704ed96c88fc9837a8)

* object: add repository argument to parse_object
  (109cd76dd3467bd05f8d2145b857006649741d5c)

* tag: add repository argument to deref_tag
  (a74093da5ed601a09fa158e5ba6f6f14c1142a3e)

* tag: add repository argument to lookup_tag
  (ce71efb713f97f476a2d2ab541a0c73f684a5db3)

* tree: add repository argument to lookup_tree
  (f86bcc7b2ce6cad68ba1a48a528e380c6126705e)

* archive.c: avoid access to the_index
  (b612ee202a48f129f81f8f6a5af6cf71d1a9caef)

* for_each_*_object: move declarations to object-store.h
  (0889aae1cd18c1804ba01c1a4229e516dfb9fe9b)

Signed-off-by: Christian Hesse <mail@eworm.de>
6 years ago
Christian Hesse 255b78ff52 git: update to v2.18.0
Update to git version v2.18.0. Required changes follow upstream commits:

* Convert find_unique_abbrev* to struct object_id
  (aab9583f7b5ea5463eb3f653a0b4ecac7539dc94)
* sha1_file: convert read_sha1_file to struct object_id
  (b4f5aca40e6f77cbabcbf4ff003c3cf30a1830c8)
* sha1_file: convert sha1_object_info* to object_id
  (abef9020e3df87c441c9a3a95f592fce5fa49bb9)
* object-store: move packed_git and packed_git_mru to object store
  (a80d72db2a73174b3f22142eb2014b33696fd795)
* treewide: rename tree to maybe_tree
  (891435d55da80ca3654b19834481205be6bdfe33)

The changed data types required some of our own functions to be converted
to struct object_id:

  ls_item
  print_dir
  print_dir_entry
  print_object
  single_tree_cb
  walk_tree
  write_tree_link

And finally we use new upstream functions that were added for
struct object_id:

  hashcpy     -> oidcpy
  sha1_to_hex -> oid_to_hex

Signed-off-by: Christian Hesse <mail@eworm.de>
Reviewed-by: John Keeping <john@keeping.me.uk>
6 years ago
Christian Hesse 1dd53e3a2f git: update to v2.16.0
Update to git version v2.16.0:

* refs: convert resolve_ref_unsafe to struct object_id
  (49e61479be913f67e66bb3fdf8de9475c41b58bd)
* diff: remove DIFF_OPT_SET macro
  (23dcf77f48feb49c54bad09210f093a799816334)
* log: add option to choose which refs to decorate
  (65516f586b69307f977cd67cc45513a296cabc25)
* diff: convert flags to be stored in bitfields
  (02f2f56bc377c287c411947d0e1482aac888f8db)

Signed-off-by: Christian Hesse <mail@eworm.de>
6 years ago
Jeff Smith 86a6d358f7 git: update to v2.14
Numerous changes were made to git functions to use an object_id
structure rather than sending sha1 hashes as raw unsigned character
arrays.  The functions that affect cgit are: parse_object,
lookup_commit_reference, lookup_tag, lookup_tree, parse_tree_indirect,
diff_root_tree_sha1, diff_tree_sha1, and format_display_notes.

Commit b2141fc (config: don't include config.h by default) made it
necessary to that config.h be explicitly included when needed.

Commit 07a3d41 (grep: remove regflags from the public grep_opt API)
removed one way of specifying the ignore-case grep option.

Signed-off-by: Jeff Smith <whydoubt@gmail.com>
7 years ago
Christian Hesse 11695a58fd git: update to v2.10.0
Upstream continues to replace unsigned char *sha1 with struct
object_id old_oid. This makes the required changes.

The git lib has its own main function now. Rename our main function
to cmd_main, it is called from main then.
8 years ago
Jason A. Donenfeld 21bf30b043 ui-diff: action='.' is not correct
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
8 years ago
Christian Hesse 559ab5ecc4 git: update to v2.7.0
Update to git version v2.7.0.

* Upstream commit ed1c9977cb1b63e4270ad8bdf967a2d02580aa08 (Remove
  get_object_hash.) changed API:

  Convert all instances of get_object_hash to use an appropriate
  reference to the hash member of the oid member of struct object.
  This provides no functional change, as it is essentially a macro
  substitution.

Signed-off-by: Christian Hesse <mail@eworm.de>
8 years ago
John Keeping 3b220eb22d diff: move layout to page function
The existing "show_ctrls" flag is used to control whether we are running
in an existing page or control the page ourselves.

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years ago
John Keeping 30304d8156 log: allow users to follow a file
Teach the "log" UI to behave in the same way as "git log --follow", when
given a suitable instruction by the user.  The default behaviour remains
to show the log without following renames, but the follow behaviour can
be activated by following a link in the page header.

Follow is not the default because outputting merges in follow mode is
tricky ("git log --follow" will not show merges).  We also disable the
graph in follow mode because the commit graph is not simplified so we
end up with frequent gaps in the graph and many lines that do not
connect with any commits we're actually showing.

We also teach the "diff" and "commit" UIs to respect the follow flag on
URLs, causing the single-file version of these UIs to detect renames.
This feature is needed only for commits that rename the path we're
interested in.

For commits before the file has been renamed (i.e. that appear later in
the log list) we change the file path in the links from the log to point
to the old name; this means that links to commits always limit by the
path known to that commit.  If we didn't do this we would need to walk
down the log diff'ing every commit whenever we want to show a commit.
The drawback is that the "Log" link in the top bar of such a page links
to the log limited by the old name, so it will only show pre-rename
commits.  I consider this a reasonable trade-off since the "Back" button
still works and the log matches the path displayed in the top bar.

Since following renames requires running diff on every commit we
consider, I've added a knob to the configuration file to globally
enable/disable this feature.  Note that we may consider a large number
of commits the revision walking machinery no longer performs any path
limitation so we have to examine every commit until we find a page full
of commits that affect the target path or something related to it.

Suggested-by: René Neumann <necoro@necoro.eu>
Signed-off-by: John Keeping <john@keeping.me.uk>
9 years ago
John Keeping 12d3d4c3ed Avoid signed bitfields
Bitfields are only defined for unsigned types.

Detected by sparse.

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years ago
John Keeping e3d3fffdd4 Avoid non-ANSI function declarations
Sparse says things like:

	warning: non-ANSI function declaration of function 'calc_ttl'

Signed-off-by: John Keeping <john@keeping.me.uk>
9 years ago
John Keeping d6c4050771 ui-diff: don't link to single file diff stat
Seeing the diff stat for a single file is pretty useless, so reset the
diff type before generating the links to individual files in the diff
stat so that the links will show a useful diff.

Reported-by: Konstantin Ryabitsev <mricon@kernel.org>
Signed-off-by: John Keeping <john@keeping.me.uk>
9 years ago
John Keeping ddfaef6bb2 ui-diff: add "stat only" diff type
This prints the diffstat but stops before printing (or generating) any
of the body of the diff.

No cgitrc option is added here so that we can wait to see how useful
this is before letting people set it as the default.

Suggested-by: Konstantin Ryabitsev <mricon@kernel.org>
Signed-off-by: John Keeping <john@keeping.me.uk>
10 years ago
John Keeping 1830271c59 Change "ss" diff flag to an enum
This will allow us to introduce a new "stat only" diff mode without
needing an explosion of mutually incompatible flags.

The old "ss" query parameter is still accepted in order to avoid
breaking saved links, but we no longer generate any URIs using it;
instead the new "dt" (diff type) parameter is used.

Signed-off-by: John Keeping <john@keeping.me.uk>
10 years ago
John Keeping 03f537f1a1 ui-shared: remove toggle_ssdiff arg to cgit_diff_link()
This argument is never used with a value other than zero, so remove it
and simplify the code.

Signed-off-by: John Keeping <john@keeping.me.uk>
10 years ago
Lukas Fleischer f60ffa143c Switch to exclusively using global ctx
Drop the context parameter from the following functions (and all static
helpers used by them) and use the global context instead:

* cgit_print_http_headers()
* cgit_print_docstart()
* cgit_print_pageheader()

Remove context parameter from all commands

Drop the context parameter from the following functions (and all static
helpers used by them) and use the global context instead:

* cgit_get_cmd()
* All cgit command functions.
* cgit_clone_info()
* cgit_clone_objects()
* cgit_clone_head()
* cgit_print_plain()
* cgit_show_stats()

In initialization routines, use the global context variable instead of
passing a pointer around locally.

Remove callback data parameter for cache slots

This is no longer needed since the context is always read from the
global context variable.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
10 years ago
Lukas Fleischer f7f26f8875 Update copyright information
* Name "cgit Development Team" as copyright holder to avoid listing
  every single developer.

* Update copyright ranges.

Signed-off-by: Lukas Fleischer <cgit@crytocrack.de>
10 years ago
Lukas Fleischer 2da46fe5aa ui-diff: Use diff_tree_sha1() for raw diff formatting
Use Git's internal diff_tree_sha1() function for the /rawdiff/ command
instead of trying to recreate this functionality.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years ago
Lukas Fleischer 01db083729 ui-diff: Check the return value of get_sha1()
Sync with what we do everywhere else and check the return value of
get_sha1() instead of calling sha1_object_info() to validate the object.
Note that we later call lookup_commit_reference(), which checks that
both SHA1 values refer to commits, anyway.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years ago
Lukas Fleischer 9003cc172a Allow for creating raw diffs with cgit_print_diff()
This adds a parameter to cgit_print_diff() to create raw diffs, using
the same format as `git diff <commit>`.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years ago
John Keeping ed5bd30ebe Convert cgit_print_error to a variadic function
This removes many uses of "fmt" which uses a fixed size static pool of
fixed size buffers.  Instead of relying on these, we now pass around
argument lists for as long as possible before using a strbuf to render
content of an arbitrary size.

Signed-off-by: John Keeping <john@keeping.me.uk>
11 years ago
John Keeping 8f20879431 Always #include corresponding .h in .c files
While doing this, remove declarations from header files where the
corresponding definition is declared "static" in order to avoid build
errors.

Also re-order existing headers in ui-*.c so that the file-specific
header always comes immediately after "cgit.h", helping with future
consistency.

Signed-off-by: John Keeping <john@keeping.me.uk>
11 years ago
Lukas Fleischer bafab423f2 Mark several functions/variables static
Spotted by parsing the output of `gcc -Wmissing-prototypes [...]`.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years ago
Jason A. Donenfeld bdae1d8a8d White space around control verbs.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
11 years ago
Michael Halstead 62a40c78fe Format git diff headers correctly when adding or removing files.
Copying the output of cgit and using it in patches now works when adding
files to or removing files from the repository. This is helpful for people
who use cgit in their patch workflow.
12 years ago
Tim Chen 1957425726 ui-ssdiff.c: set correct diffmode in "control panel"
When side-by-side-diffs=1 was set in cgitrc, specifying 'ss=0' in the
querystring would not set the 'unified' option as active in the dropdown
box used to select diffmode.
13 years ago
Lars Hjemli 04254fa903 Merge branch 'stable' 13 years ago
Tim Chen f2ced535e9 Fix diff mode switching when side-by-side-diffs=1
When side-by-side-diffs=1 was set in cgitrc, specyfing 'ss=0' in the query-
string would not switch to unified diffs. This patch fixes the issue by
introducing a separate variable to track the occurrence of "ss" in the
querystring.
13 years ago
Lars Hjemli 756e3ea639 Merge branch 'stable' 13 years ago
Lukas Fleischer bebe89d7c1 Fix potential XSS vulnerability in rename hint
The file name displayed in the rename hint should be escaped to avoid
XSS. Note that this vulnerability is only applicable when an attacker
has gained push access to the repository.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
13 years ago
Lars Hjemli 2ffeecb7a6 Merge branch 'lh/panel' 13 years ago
Lukas Fleischer 9afc883297 Avoid null pointer dereference in cgit_print_diff().
When calling cgit_print_diff() with a bad new_rev and a NULL old_rev,
checking for new_rev's parent commit will result in a null pointer
dereference. Returning on an invalid commit before dereferencing fixes
this. Spotted with clang-analyzer.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
13 years ago
Lars Hjemli 962a24892f ui-diff.c: create a control panel for diff options
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
13 years ago
Lukasz Janyst 7f3c6e0ce9 ui-diff.c: avoid html injection
When path-filtering was used in commit-view, the path filter was
included without proper html escaping. This patch closes the hole.

Signed-off-by: Lukasz Janyst <ljanyst@cern.ch>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
13 years ago
Bernhard Reutner-Fischer e52040bf90 ssdiff: anchors for ssdiff
Emit anchors to the respective revisions in side-by-side diff view

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
13 years ago
Mark Lodato e4ddc8f72b fix errors in printf-style format strings
There were many places where the arguments to a printf-like function did
not match the format string.  Mostly, these were a missing 'l' flag, but
there were three exceptions:

- In ui-stats.c, a size_t argument must be printed.  C99 has the "%zu"
  flag for this purpose, but not all compilers support this.  Therefore,
  we mimic what git does - use a NO_C99_FORMAT Makefile variable.

- In ui-stats.c, cgit_print_error() was called with a pointer instead of
  a character.

- In ui-log.c, the "columns" argument was never used.

Signed-off-by: Mark Lodato <lodatom@gmail.com>
14 years ago
Johan Herland 72ef913514 ui-diff: Add link to ignore/show whitespace changes in diffs
Add a link to the "Diffstat" line to ignore/show whitespace changes in the
generated diff.

To support this, cgit_commit_link() and cgit_diff_link() has learned to
preserve the ctx.qry.ignorews variable.

Signed-off-by: Johan Herland <johan@herland.net>
14 years ago
Johan Herland 2cc8b99f08 Add URL parameter 'ignorews' for optionally ignoring whitespace in diffs
The new ctx.qry.ignorews variable is passed via cgit_diff_files() and
cgit_diff_tree() to Git's diff machinery. This is equivalent to passing
--ignore-all-space to 'git diff'.

Signed-off-by: Johan Herland <johan@herland.net>
14 years ago
Johan Herland d20313e3da ui-diff: Add links to increase/decrease number of context lines in diffs
Add two links to the "Diffstat" line to show more/less context lines in the
generated diff.

To support this, cgit_commit_link() and cgit_diff_link() has learned to
preserve the ctx.qry.context variable.

Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
14 years ago
Johan Herland 6180e6169d Add URL parameter 'context' for changing the number of context lines in diffs
The new ctx.qry.context variable is picked up by cgit_print_diff(), and
passed via cgit_diff_files() to Git's diff machinery.

Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
14 years ago
Johan Herland c46e468dd2 ui-diff: Teach diffstat to obey path limit
Also indicate in the diffstat header if a path limit is in effect.

Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
14 years ago
Ragnar Ouchterlony 4a198e4b8e Fixed side-by-side diff bugs related to binary diff and more.
The fixed bugs:

 * "Binary files differ" did not show up either in unidiff or
   side-by-side-diff.
 * Subproject diffs did not work for side-by-side diffs.
 * The ssdiff link on diff pages did not conserve the path.

Signed-off-by: Ragnar Ouchterlony <ragnar@lysator.liu.se>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
15 years ago
Ragnar Ouchterlony 207cc34711 Polishing of how the side-by-side diff looks.
Aligned all different files, so that all side-by-side tables look
the same. Also made sure that the tables take up the whole browser
width.

Also various changes to the css to make things easier on the eye.

Signed-off-by: Ragnar Ouchterlony <ragnar@lysator.liu.se>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
15 years ago
Ragnar Ouchterlony c358aa3dfe Add possibility to switch between unidiff and side-by-side-diff.
A new config option side-by-side-diffs added, defaulting to 0,
meaning unidiff. Also a query option (ss) is used toggle this.

In the commit page you can switch between the two diff formats by
clicking on the link on the "commit"-row, to the right of (patch).

In the diff page you can switch by using the link at the start
of the page.

All commit-links and diff-links will remember the choice.

Signed-off-by: Ragnar Ouchterlony <ragnar@lysator.liu.se>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
15 years ago
Ragnar Ouchterlony 40e174d536 First version of side-by-side diff.
This constitutes the first prototype of a side-by-side diff. It is not
possible to switch between unidiff and side-by-side diff at all at this
stage.

Signed-off-by: Ragnar Ouchterlony <ragnar@lysator.liu.se>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
15 years ago
Lars Hjemli c495cf02ba Handle binary files in diffs
This teaches all diff-related operations (i.e. ui-log, ui-diff and ui-patch)
how to handle binary files.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
15 years ago
Lars Hjemli f82b19407d ui-diff: make diffstat header a link to the full diff
When printing a path-filtered diff it wasn't obvious how to get back to
the full diff (clicking the 'diff' tab would do this). Making the diffstat
heading into a link seems to improve the usability.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago