0

So I'm using etckeeper on my machine running Debian 9.1 with KDE and would like to view diffs (or if that isn't yet implemented: past versions) of specific files. How can I do that?

3

By default, with etckeeper, /etc is a git repository, so you can use git tools to view its contents (and the changes). For example, you can use gitk (after installing it) to browse the repository’s history, and if you want to focus on a specific file, you can specify it on the command line:

cd /etc
gitk apt/sources.list &

Since you’re a KDE user, you might find qgit nicer.

  • Will use that in the future. It didn't work now as I didn't initialize the database as I thought it would do that on its own - especially as I noticed how several .git folders were created automatically via some other tool. I didn't know it needed to be configured first because there was nothing on its website nor a popup / wizard after installation. But I guess people are used to reading the man pages for tools. – mYnDstrEAm Aug 6 '17 at 22:34
  • It’s generally useful to read at least the README (which in this case is quite good). – Stephen Kitt Aug 7 '17 at 7:14
1

I just use git log and git show or git diff. e.g.

# git log --oneline /etc/squid/squid.conf
907df30 saving uncommitted changes in /etc prior to apt run
a612769 daily autocommit
6d45b99 saving uncommitted changes in /etc prior to apt run
0f21707 daily autocommit
9a95a9b saving uncommitted changes in /etc prior to apt run
b2518f4 daily autocommit
338b4a7 daily autocommit
862d5e6 committing changes in /etc after apt run
ff6a8fd daily autocommit
2d64d79 saving uncommitted changes in /etc prior to apt run
7e3bb0e Initial commit


# git diff a612769 907df30 /etc/squid/squid.conf
diff --git a/squid/squid.conf b/squid/squid.conf
index 0e08217..e630ed9 100644
--- a/squid/squid.conf
+++ b/squid/squid.conf
@@ -7876,9 +7876,3 @@ forwarded_for off
 #  not all I/O types supports large values (eg on Windows).
 #Default:
 # Use operating system limits set by ulimit.
-
-#httpd_accel_host virtual
-#httpd_accel_port 80
-#httpd_accel_with_proxy on
-#httpd_accel_uses_host_header on
-

If I wanted the full contents of a specific revision of a file, I'd use git ls-tree (to get the sha1 of the file blob) and git cat-file to output it. e.g.

# git cat-file blob "$(git ls-tree a612769 /etc/squid/squid.conf | 
                       awk '{print $3}')" > /tmp/squid.conf.a612769

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.